From fd38f09a146922a899a605bfaf9c562f5ddd310e Mon Sep 17 00:00:00 2001
From: Urban Müller
Date: Tue, 16 Aug 2016 18:28:19 +0200
Subject: handle bad utf8 in ED()
---
it_debug.class | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'it_debug.class')
diff --git a/it_debug.class b/it_debug.class
index 7f51172..3cd3237 100644
--- a/it_debug.class
+++ b/it_debug.class
@@ -75,6 +75,8 @@ static function srcline($stackoffs = 0)
*/
static function dump($args)
{
+ $htmlspecialchars = array("&" => "&", '<' => "<", '>' => ">");
+
if ((preg_match('/csv|txt|gif|jpg/', $_SERVER['PHP_SELF']) || preg_grep('#text/(calendar|css|javascript|json|plain|rfc822|xml)|application/#', headers_list()) || $GLOBALS['debug_edplain']) && !$GLOBALS['debug_edhtml'])
;
else if ($_SERVER['REMOTE_ADDR'])
@@ -137,7 +139,7 @@ static function dump($args)
$item = "$red$item$nored";
if ($htmlok)
- $item = preg_replace("#(https?:)?//[^\s']*#", "\$0", htmlspecialchars($item));
+ $item = preg_replace("#(https?:)?//[^\s']*#", "\$0", strtr($item, $htmlspecialchars)); # htmlspecialchars() does not like bad utf8
if (preg_match('/^[\'"]/', $var))
$r .= "$item ";
--
cgit v1.2.3