diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index 5b3847f4a54f..e428824ae65b 100755 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -120,7 +120,7 @@ function e($value, $doubleEncode = true) $value = $value->value; } - return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode); + return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', $doubleEncode); } } diff --git a/tests/Support/SupportHelpersTest.php b/tests/Support/SupportHelpersTest.php index 1dec3cd9ad0e..aa1dda34cd74 100755 --- a/tests/Support/SupportHelpersTest.php +++ b/tests/Support/SupportHelpersTest.php @@ -37,6 +37,12 @@ public function testE() $this->assertEquals($str, e($html)); } + public function testEWithInvalidCodePoints() + { + $str = mb_convert_encoding('føø bar', 'ISO-8859-1', 'UTF-8'); + $this->assertEquals('f�� bar', e($str)); + } + /** * @requires PHP >= 8.1 */