diff options
| author | Greg Roach <fisharebest@gmail.com> | 2017-07-14 19:29:28 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2017-07-14 19:29:28 +0100 |
| commit | 85ccaa18d343e7ab7195c6896ab18d371b91327f (patch) | |
| tree | 4719c9931b0b54e4de8da8a1d5f389e3d87c85df /app/Filter.php | |
| parent | 05168efae8a3622edfdeaa2beb26320ee49abacd (diff) | |
| download | webtrees-85ccaa18d343e7ab7195c6896ab18d371b91327f.tar.gz webtrees-85ccaa18d343e7ab7195c6896ab18d371b91327f.tar.bz2 webtrees-85ccaa18d343e7ab7195c6896ab18d371b91327f.zip | |
Review esacping
Diffstat (limited to 'app/Filter.php')
| -rw-r--r-- | app/Filter.php | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/app/Filter.php b/app/Filter.php index d3f6f9f57f..6d2c90e3b9 100644 --- a/app/Filter.php +++ b/app/Filter.php @@ -31,45 +31,6 @@ class Filter { const URL_REGEX = '((https?|ftp]):)(//([^\s/?#<>]*))?([^\s?#<>]*)(\?([^\s#<>]*))?(#[^\s?#<>]+)?'; /** - * Escape a string for use in HTML - * - * @param string $string - * - * @return string - */ - public static function escapeHtml($string) { - return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); - } - - /** - * Escape a string for use in a URL - * - * @param string $string - * - * @return string - */ - public static function escapeUrl($string) { - return rawurlencode($string); - } - - /** - * Escape a string for use in Javascript - * - * @param string $string - * - * @return string - */ - public static function escapeJs($string) { - return preg_replace_callback('/[^A-Za-z0-9,. _]/Su', function ($x) { - if (strlen($x[0]) === 1) { - return sprintf('\\u%04s', strtoupper(bin2hex(mb_convert_encoding($x[0], 'UTF-16BE', 'UTF-8')))); - } else { - return $x[0]; - } - }, $string); - } - - /** * Escape a string for use in a SQL "LIKE" clause * * @param string $string @@ -117,7 +78,7 @@ class Filter { function ($m) { return '<a href="' . $m[0] . '">' . $m[0] . '</a>'; }, - self::escapeHtml($text) + Html::escape($text) ); } |
