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 committed May 1, 2023
1 parent 96f0d0e commit 812ef55
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
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
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));
}

/**
* @requires PHP >= 8.1
*/
Expand Down

0 comments on commit 812ef55

Please sign in to comment.