mirror of
https://github.com/filp/whoops.git
synced 2026-08-30 20:17:11 +00:00
TemplateHelper: silent workaround for 5.3 for d76904a
This commit is contained in:
@@ -25,7 +25,15 @@ class TemplateHelper
|
||||
*/
|
||||
public function escape($raw)
|
||||
{
|
||||
return htmlspecialchars($raw, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");
|
||||
$flags = ENT_QUOTES;
|
||||
|
||||
// On 5.3 this will return an empty string if the source contents
|
||||
// are illegal UTF-8 sequences. Oh well, 5.3.
|
||||
if (defined('ENT_SUBSTITUTE')) {
|
||||
$flags |= ENT_SUBSTITUTE;
|
||||
}
|
||||
|
||||
return htmlspecialchars($raw, $flags, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,10 @@ class TemplateHelperTest extends TestCase
|
||||
|
||||
public function testEscapeBrokenUtf8()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.4', '<')) {
|
||||
return $this->markTestSkipped();
|
||||
}
|
||||
|
||||
// The following includes an illegal utf-8 sequence to test.
|
||||
// Encoded in base64 to survive possible encoding changes of this file.
|
||||
$original = base64_decode('VGhpcyBpcyBhbiBpbGxlZ2FsIHV0Zi04IHNlcXVlbmNlOiDD');
|
||||
|
||||
Reference in New Issue
Block a user