From a6e8a48d2eb254a4854e73991b7abafa642034c4 Mon Sep 17 00:00:00 2001 From: Olu Amey Date: Sun, 19 Sep 2021 01:48:23 -0400 Subject: [PATCH] Added Tools Route --- app/Config/Routes.php | 3 + app/Controllers/Tools.php | 14 ++ app/Views/home/index.php | 36 ++---- app/Views/tools/index.php | 3 + system/ThirdParty/Escaper/Escaper.php | 121 +++++++++++------- .../Escaper/Exception/ExceptionInterface.php | 6 +- .../Exception/InvalidArgumentException.php | 6 +- .../Escaper/Exception/RuntimeException.php | 6 +- 8 files changed, 109 insertions(+), 86 deletions(-) create mode 100644 app/Controllers/Tools.php create mode 100644 app/Views/tools/index.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 84db0ba..a67b5f8 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -38,6 +38,9 @@ $routes->get('/security', 'Home::security'); $routes->get('/terms', 'Home::terms'); $routes->get('/privacy', 'Home::privacy'); $routes->get('/contact', 'Home::contact'); +$routes->get('/howitworks', 'Home::howitworks'); + +$routes->get('/tools', 'Tools::index'); /* * -------------------------------------------------------------------- * Additional Routing diff --git a/app/Controllers/Tools.php b/app/Controllers/Tools.php new file mode 100644 index 0000000..bd31ceb --- /dev/null +++ b/app/Controllers/Tools.php @@ -0,0 +1,14 @@ +PLANS
  • APP
  • CONTACT
  • -
  • START
  • + +
  • START
  • @@ -330,8 +331,9 @@ @@ -339,10 +341,10 @@ @@ -350,8 +352,8 @@ @@ -408,23 +410,5 @@ - - - - - - \ No newline at end of file diff --git a/app/Views/tools/index.php b/app/Views/tools/index.php new file mode 100644 index 0000000..3c5fbc2 --- /dev/null +++ b/app/Views/tools/index.php @@ -0,0 +1,3 @@ + 'quot', // quotation mark - 38 => 'amp', // ampersand - 60 => 'lt', // less-than sign - 62 => 'gt', // greater-than sign + 34 => 'quot', // quotation mark + 38 => 'amp', // ampersand + 60 => 'lt', // less-than sign + 62 => 'gt', // greater-than sign ]; /** @@ -73,42 +90,61 @@ class Escaper * @var array */ protected $supportedEncodings = [ - 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', - 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', - 'ibm866', '866', 'cp1251', 'windows-1251', - 'win-1251', '1251', 'cp1252', 'windows-1252', - '1252', 'koi8-r', 'koi8-ru', 'koi8r', - 'big5', '950', 'gb2312', '936', - 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', - 'cp932', '932', 'euc-jp', 'eucjp', - 'eucjp-win', 'macroman' + 'iso-8859-1', + 'iso8859-1', + 'iso-8859-5', + 'iso8859-5', + 'iso-8859-15', + 'iso8859-15', + 'utf-8', + 'cp866', + 'ibm866', + '866', + 'cp1251', + 'windows-1251', + 'win-1251', + '1251', + 'cp1252', + 'windows-1252', + '1252', + 'koi8-r', + 'koi8-ru', + 'koi8r', + 'big5', + '950', + 'gb2312', + '936', + 'big5-hkscs', + 'shift_jis', + 'sjis', + 'sjis-win', + 'cp932', + '932', + 'euc-jp', + 'eucjp', + 'eucjp-win', + 'macroman', ]; /** * Constructor: Single parameter allows setting of global encoding for use by * the current object. * - * @param string $encoding * @throws Exception\InvalidArgumentException */ - public function __construct($encoding = null) + public function __construct(?string $encoding = null) { if ($encoding !== null) { - if (! is_string($encoding)) { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) - ); - } if ($encoding === '') { throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter does not allow a blank value' + static::class . ' constructor parameter does not allow a blank value' ); } $encoding = strtolower($encoding); if (! in_array($encoding, $this->supportedEncodings)) { throw new Exception\InvalidArgumentException( - 'Value of \'' . $encoding . '\' passed to ' . get_class($this) + 'Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' ); } @@ -139,10 +175,9 @@ class Escaper * Escape a string for the HTML Body context where there are very few characters * of special meaning. Internally this will use htmlspecialchars(). * - * @param string $string * @return string */ - public function escapeHtml($string) + public function escapeHtml(string $string) { return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); } @@ -152,10 +187,9 @@ class Escaper * to escape that are not covered by htmlspecialchars() to cover cases where an attribute * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). * - * @param string $string * @return string */ - public function escapeHtmlAttr($string) + public function escapeHtmlAttr(string $string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { @@ -175,10 +209,9 @@ class Escaper * Backslash escaping is not used as it still leaves the escaped character as-is and so * is not useful in a HTML context. * - * @param string $string * @return string */ - public function escapeJs($string) + public function escapeJs(string $string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { @@ -194,10 +227,9 @@ class Escaper * an entire URI - only a subcomponent being inserted. The function is a simple proxy * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. * - * @param string $string * @return string */ - public function escapeUrl($string) + public function escapeUrl(string $string) { return rawurlencode($string); } @@ -206,10 +238,9 @@ class Escaper * Escape a string for the CSS context. CSS escaping can be applied to any string being * inserted into CSS and escapes everything except alphanumerics. * - * @param string $string * @return string */ - public function escapeCss($string) + public function escapeCss(string $string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { @@ -236,7 +267,8 @@ class Escaper * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") + if ( + ($ord <= 0x1f && $chr !== "\t" && $chr !== "\n" && $chr !== "\r") || ($ord >= 0x7f && $ord <= 0x9f) ) { return '�'; @@ -276,7 +308,7 @@ class Escaper protected function jsMatcher($matches) { $chr = $matches[0]; - if (strlen($chr) == 1) { + if (strlen($chr) === 1) { return sprintf('\\x%02X', ord($chr)); } $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); @@ -285,7 +317,7 @@ class Escaper return sprintf('\\u%04s', $hex); } $highSurrogate = substr($hex, 0, 4); - $lowSurrogate = substr($hex, 4, 4); + $lowSurrogate = substr($hex, 4, 4); return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); } @@ -299,7 +331,7 @@ class Escaper protected function cssMatcher($matches) { $chr = $matches[0]; - if (strlen($chr) == 1) { + if (strlen($chr) === 1) { $ord = ord($chr); } else { $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); @@ -310,7 +342,6 @@ class Escaper /** * Converts a string to UTF-8 from the base encoding. The base encoding is set via this - * class' constructor. * * @param string $string * @throws Exception\RuntimeException @@ -335,7 +366,7 @@ class Escaper /** * Converts a string from UTF-8 to the base encoding. The base encoding is set via this - * class' constructor. + * * @param string $string * @return string */ @@ -356,7 +387,7 @@ class Escaper */ protected function isUtf8($string) { - return ($string === '' || preg_match('/^./su', $string)); + return $string === '' || preg_match('/^./su', $string); } /** @@ -377,7 +408,7 @@ class Escaper $result = mb_convert_encoding($string, $to, $from); } else { throw new Exception\RuntimeException( - get_class($this) + static::class . ' requires either the iconv or mbstring extension to be installed' . ' when escaping for non UTF-8 strings.' ); diff --git a/system/ThirdParty/Escaper/Exception/ExceptionInterface.php b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php index 7ebe04e..87edfd2 100644 --- a/system/ThirdParty/Escaper/Exception/ExceptionInterface.php +++ b/system/ThirdParty/Escaper/Exception/ExceptionInterface.php @@ -1,10 +1,6 @@