Skip to content

Commit 13f8fd8

Browse files
committed
Check encoding before applying htmlentities
Fix for php-debugbar#48
1 parent 57344cc commit 13f8fd8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/DebugBar/DataCollector/DataCollector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public function flattenVar($var)
4141
}
4242
} else if (is_object($var)) {
4343
$var = "Object(" . get_class($var) . ")";
44-
} else {
44+
} else if (mb_check_encoding($var, 'UTF-8')) {
4545
$var = htmlentities($var, ENT_QUOTES, 'UTF-8', false);
46+
} else {
47+
$var = '[Invalid UTF-8 string]';
4648
}
4749
return $var;
4850
}

0 commit comments

Comments
 (0)