mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
AK: Simplify BOM parsing in String::from_utf8_with_replacement_character
This commit is contained in:
parent
f098bd029c
commit
51afbf5280
Notes:
github-actions[bot]
2025-07-05 16:31:25 +00:00
Author: https://github.com/trflynn89
Commit: 51afbf5280
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5313
Reviewed-by: https://github.com/shannonbooth ✅
1 changed files with 1 additions and 1 deletions
|
@ -24,7 +24,7 @@ namespace AK {
|
|||
|
||||
String String::from_utf8_with_replacement_character(StringView view, WithBOMHandling with_bom_handling)
|
||||
{
|
||||
if (auto bytes = view.bytes(); with_bom_handling == WithBOMHandling::Yes && bytes.size() >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
|
||||
if (auto bytes = view.bytes(); with_bom_handling == WithBOMHandling::Yes && bytes.starts_with({ { 0xEF, 0xBB, 0xBF } }))
|
||||
view = view.substring_view(3);
|
||||
|
||||
if (Utf8View(view).validate())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue