summaryrefslogtreecommitdiff
path: root/it_html.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_html.class')
-rw-r--r--it_html.class15
1 files changed, 11 insertions, 4 deletions
diff --git a/it_html.class b/it_html.class
index 92aa9ba..1aeed94 100644
--- a/it_html.class
+++ b/it_html.class
@@ -38,7 +38,7 @@ function it_html($p = array())
{
# Default configuration of html class
$this->p = $p + array(
- 'charset' => 'iso-8859-1',
+ 'charset' => ini_get('default_charset') ?: 'iso-8859-1',
'doctype' => null, # Custom doctype (will usually be calculated from htmltype)
'head' => '', # Code to put into head() section
'htmltype' => 'xhtml', # 'html' (=old-style), 'xhtml' or 'xhtml-mobile'
@@ -312,6 +312,12 @@ function _tag($name, $args)
else
$result .= " />$newline";
+ if ($GLOBALS['debug_utf8check'] && $GLOBALS['it_html']->p['charset'] == "utf-8" && preg_match('/[\x20-\x7f][\x80-\xff][\x20-\x7f]/', $result))
+ {
+ it::error(array('title' => utf8_encode("incorrectly utf8-encoded: " . trim($result)), 'skipfiles' => "it_html"));
+ $result = utf8_encode($result);
+ }
+
return $result;
}
@@ -454,7 +460,7 @@ function sanitize($html)
*/
function entity_decode($string)
{
- $string = preg_replace('/&#(8217|65533);/', "'", html_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);
@@ -476,8 +482,9 @@ function latinize($string)
*/
function Q($string)
{
- if (preg_match('/[<>&"\x00-\x08\x0a-\x0c\x0e-\x1f\x80-\x9f]/', $string)) # WARNING: copy/pasted to _tag()
- $string = htmlspecialchars($GLOBALS['it_html']->p['charset'] == "iso-8859-1" ? it_html::latinize($string) : $string, ENT_COMPAT, $GLOBALS['it_html']->p['charset']);
+ if (preg_match('/[<>&"\x00-\x08\x0a-\x0c\x0e-\x1f\x80-\xff]/', $origstring = $string)) # WARNING: copy/pasted to _tag()
+ if (($string = htmlspecialchars($GLOBALS['it_html']->p['charset'] == "iso-8859-1" ? it_html::latinize($string) : $string, ENT_COMPAT, $GLOBALS['it_html']->p['charset'])) === "" && $GLOBALS['debug_utf8check'])
+ it::error(array('title' => utf8_encode("incorrectly utf8-encoded: " . trim($origstring)), 'skipfiles' => "it_html"));
return $GLOBALS['debug_q'] && $string ? "<span style='background:#8FF'>$string</span>" : $string;
}