Skip to content

Commit

Permalink
follow default PHP behavior and replace invalid codepoints (laravel#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
crishoj authored and milwad-dev committed May 12, 2023
1 parent 752213c commit 16e3f92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Support/SupportHelpersTest.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

public function testEWithEnums()
{
$enumValue = StringBackedEnum::ADMIN_LABEL;
Expand Down

0 comments on commit 16e3f92

Please sign in to comment.