Revision 468
Added by Matthias over 17 years ago
functions.php | ||
---|---|---|
340 | 340 |
|
341 | 341 |
// Function as replecement for php's htmlspecialchars() |
342 | 342 |
function my_htmlspecialchars($string) { |
343 |
$string = umlauts_to_entities($string); |
|
344 |
$string = entities_to_umlauts($string, DEFAULT_CHARSET, 1); |
|
343 |
$string = strtr($string, array("<"=>"<", ">"=>">", "\""=>""", "\'"=>"'")); |
|
345 | 344 |
return($string); |
346 | 345 |
} |
347 | 346 |
|
... | ... | |
402 | 401 |
} |
403 | 402 |
} |
404 | 403 |
} else { |
404 |
$string = strtr($string, array("<"=>"&_lt;", ">"=>"&_gt;", "&"=>"&_amp;", """=>"&_quot;", "'"=>"&_#039;")); |
|
405 | 405 |
$string=mb_convert_encoding($string, $charset_out, $charset_in); |
406 |
$string = strtr($string, array("&_lt;"=>"<", "&_gt;"=>">", "&_amp;"=>"&", "&_quot;"=>""", "&_#039;"=>"'")); |
|
406 | 407 |
} |
407 | 408 |
return $string; |
408 | 409 |
} |
... | ... | |
475 | 476 |
$string = $match[2]; |
476 | 477 |
} |
477 | 478 |
$string = $char; |
478 |
$string_htmlspecialchars_decode=array("<"=>"<", ">"=>">", "&"=>"&", """=>"\"", "'"=>"\'"); |
|
479 |
$string = strtr($string, $string_htmlspecialchars_decode); |
|
480 | 479 |
$string = strtr($string, $numbered_to_named_entities); |
481 | 480 |
} |
482 | 481 |
return $string; |
... | ... | |
606 | 605 |
$charset_out = strtoupper($charset_out); |
607 | 606 |
if ($charset_out == '') { $charset_out = 'ISO-8859-1'; } |
608 | 607 |
$string = string_to_utf8($string); |
609 |
if($convert_htmlspecialchars == 1) { |
|
610 |
$string=htmlspecialchars($string); |
|
611 |
} |
|
612 | 608 |
if($charset_out!='UTF-8' && is_UTF8($string)) { |
613 | 609 |
$string=mb_convert_encoding_wrapper($string, $charset_out, 'UTF-8'); |
614 | 610 |
} |
... | ... | |
616 | 612 |
} |
617 | 613 |
|
618 | 614 |
// Function to convert a string from mixed html-entitites/$charset_in-umlauts to pure html-entities |
619 |
function umlauts_to_entities($string, $charset_in=DEFAULT_CHARSET, $convert_htmlspecialchars=1) {
|
|
615 |
function umlauts_to_entities($string, $charset_in=DEFAULT_CHARSET, $convert_htmlspecialchars=0) {
|
|
620 | 616 |
$charset_in = strtoupper($charset_in); |
621 | 617 |
if ($charset_in == "") { $charset_in = 'ISO-8859-1'; } |
622 | 618 |
$string = string_to_utf8($string, $charset_in); |
623 |
if($convert_htmlspecialchars == 1) { |
|
624 |
$string=htmlspecialchars($string,ENT_QUOTES); |
|
625 |
} |
|
626 | 619 |
if (is_UTF8($string)) { |
627 | 620 |
$string=mb_convert_encoding_wrapper($string,'HTML-ENTITIES','UTF-8'); |
628 | 621 |
} |
Also available in: Unified diff
Fixed bug in search with some html tags (Thanks to thorn)