diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2006-11-03 11:26:14 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2006-11-03 11:26:14 +0000 |
commit | daa3288a368ddac0335dde7ee2a718883bfb2fdc (patch) | |
tree | ddca8411bb3c8fc81050ea1e654a8ea726d9c5a0 /phpBB/includes/utf | |
parent | a3bf1ed63ec7aa281b0d47d6f3e87eeeeafbaff5 (diff) | |
download | forums-daa3288a368ddac0335dde7ee2a718883bfb2fdc.tar forums-daa3288a368ddac0335dde7ee2a718883bfb2fdc.tar.gz forums-daa3288a368ddac0335dde7ee2a718883bfb2fdc.tar.bz2 forums-daa3288a368ddac0335dde7ee2a718883bfb2fdc.tar.xz forums-daa3288a368ddac0335dde7ee2a718883bfb2fdc.zip |
- implemented the suggested html_entity_decode function made by david
- fixed string length checking by also decoding entities for the sake of checking
- used the new html_entity_decode function
git-svn-id: file:///svn/phpbb/trunk@6545 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 24aeb35d02..fdf68d092e 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -8,7 +8,7 @@ * * @todo make sure the replacements are called correctly * already done: strtolower, strtoupper, ucfirst, str_split, strrpos, strlen (hopefully!), strpos, substr -* remaining: clean_username, htmlentities (no longer needed for internal data?), htmlspecialchars (using charset), html_entity_decode (own function to reverse htmlspecialchars and not htmlentities) +* remaining: clean_username, htmlentities (no longer needed for internal data?), htmlspecialchars (using charset) * strspn, chr, ord */ @@ -929,6 +929,9 @@ function utf8_case_fold($text, $option = 'full') return $text; } +/** +* @todo needs documenting +*/ function utf8_clean_string($text) { $text = utf8_case_fold($text); @@ -964,4 +967,44 @@ function utf8_clean_string($text) return $text; } +if (version_compare(phpversion(), '5', '>=')) +{ + /** + * @ignore + */ + function utf8_html_entity_decode($string, $quote_style = ENT_COMPAT) + { + return html_entity_decode($string, $quote_style, 'UTF-8'); + } +} +else +{ + /** + * @todo needs documenting + */ + function utf8_html_entity_decode($string, $quote_style = ENT_COMPAT) + { + static $static_table; + + if ($static_table === null) + { + $static_table = array_map('utf8_encode', array_flip(get_html_translation_table(HTML_ENTITIES))); + } + + $modified_table = $static_table; + + if ($quote_style === ENT_QUOTES) + { + $modified_table['''] = "'"; + } + + if ($quote_style === ENT_NOQUOTES) + { + unset($modified_table['"']); + } + + return strtr($string, $modified_table); + } +} + ?>
\ No newline at end of file |