Skip to content

Commit 812ef55

Browse files
authored
follow default PHP behavior and replace invalid codepoints (#46914)
1 parent 96f0d0e commit 812ef55

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Illuminate/Support/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function e($value, $doubleEncode = true)
120120
$value = $value->value;
121121
}
122122

123-
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode);
123+
return htmlspecialchars($value ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8', $doubleEncode);
124124
}
125125
}
126126

tests/Support/SupportHelpersTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ public function testE()
3737
$this->assertEquals($str, e($html));
3838
}
3939

40+
public function testEWithInvalidCodePoints()
41+
{
42+
$str = mb_convert_encoding('føø bar', 'ISO-8859-1', 'UTF-8');
43+
$this->assertEquals('f�� bar', e($str));
44+
}
45+
4046
/**
4147
* @requires PHP >= 8.1
4248
*/

0 commit comments

Comments
 (0)