Topic: Bug: img with data tags are ill-escaped
I am not sure if this is the right place to report a bug and a fix, but i guess i at least try.
When you have an img with an data tag, base64 encoded png or similar, it can happen that the regular expression
if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){
picks up the whole tag an replaces <> with '<', '>' so
<img src="..">
That marks the document broken. We patched this so it does not do that if that is an data:image tag, see the patch agains below 1.2.4.2
@@ -425,7 +425,11 @@
if($t == '< '){return '< ';}
if($t == '>'){return '>';}
if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){
- return str_replace(array('<', '>'), array('<', '>'), $t);
+ if(strstr($t, 'data:image')){
+ return $t;
+ }else{
+ return str_replace(array('<', '>'), array('&lt;', '&gt;'), $t);
+ }
}elseif(!isset($C['elements'][($e = strtolower($m[2]))])){
return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : '');
}
it does not break current behavior as far as we could test it