summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_html.class3
-rwxr-xr-xtests/it_html.t1
2 files changed, 2 insertions, 2 deletions
diff --git a/it_html.class b/it_html.class
index ece7070..bf9f8ff 100644
--- a/it_html.class
+++ b/it_html.class
@@ -459,8 +459,7 @@ function sanitize($html)
function entity_decode($string)
{
$string = preg_replace('/&#(8217|65533);/', "'", html_entity_decode($string, ENT_COMPAT, $GLOBALS['it_html']->p['charset']));
- $string = preg_replace_callback('/&#x0*([0-9a-f]+);/i', function($m) { return hexdec($m[1]) <= 255 ? chr(hexdec($m[1])) : " "; }, $string);
- $string = preg_replace_callback('/&#0*([0-9]+);/', function($m) { return $m[1] <= 255 ? chr($m[1]) : " "; }, $string);
+ $string = preg_replace('/&#[^;]*;/i', " ", $string); # remove remaining illegal numeric entities, e.g. 0x80-0x9f
return $string;
}
diff --git a/tests/it_html.t b/tests/it_html.t
index 307bc7f..7e43faa 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -169,6 +169,7 @@ is(
is(it_html::entity_decode("&#8217;"), "'", "it_html::entity_decode numeric decimal entity");
is(it_html::entity_decode("&#xfff;"), " ", "it_html::entity_decode invalid numeric hex entity");
is(it_html::entity_decode("&#999;"), " ", "it_html::entity_decode invalid numeric decimal entity");
+is(it_html::entity_decode("&#x8b;"), " ", "it_html::entity_decode entity von 0x80-0x9f");
?>