PDA

View Full Version : Hex htmlentities


renehaentjens
11-24-2003, 04:39 AM
I'm checking a couple of things in phpDig 1.6.4.

In robot_functions.php, the function phpdigCleanHtml has a line:$text = ereg_replace('&#([0-9]+);',chr('\1').' ',$text);
I guess that this line recognises entities such as ' & # 233; ' as being lowercase e with acute accent.

I see no code to recognise equivalent entities such as ' & # x e9; '. If these hex entities aren't currently recognised, could the code be added to recognise them?

Charter
11-24-2003, 06:13 PM
Hi. In robot_functions find:

$text = ereg_replace('&#([0-9]+);',chr('\\1').' ',$text);

and replace with:

while (eregi('&#([0-9]{3});',$text,$reg)) {
$text = str_replace($reg[0],chr($reg[1]),$text);
}
while (eregi('&#x([a-f0-9]{2});',$text,$reg)) {
$text = str_replace($reg[0],chr(base_convert($reg[1],16,10)),$text);
}

renehaentjens
11-27-2003, 07:48 AM
Thanks. I'll make a test as soon as I can.

renehaentjens
12-08-2003, 03:44 AM
Works OK for me now. Thanks.