mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibTextCodec: Replace unmatched utf16 surrogates
This commit is contained in:
parent
1b8a77f98c
commit
f098bd029c
Notes:
github-actions[bot]
2025-07-05 14:00:10 +00:00
Author: https://github.com/Gingeh
Commit: f098bd029c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5266
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/trflynn89
6 changed files with 102 additions and 10 deletions
|
@ -381,7 +381,7 @@ ErrorOr<String> UTF16BEDecoder::to_utf8(StringView input)
|
|||
if (auto bytes = input.bytes(); bytes.size() >= 2 && bytes[0] == 0xFE && bytes[1] == 0xFF)
|
||||
input = input.substring_view(2);
|
||||
|
||||
return String::from_utf16_be(input.bytes());
|
||||
return String::from_utf16_be_with_replacement_character(input.bytes());
|
||||
}
|
||||
|
||||
bool UTF16LEDecoder::validate(StringView input)
|
||||
|
@ -395,7 +395,7 @@ ErrorOr<String> UTF16LEDecoder::to_utf8(StringView input)
|
|||
if (auto bytes = input.bytes(); bytes.size() >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE)
|
||||
input = input.substring_view(2);
|
||||
|
||||
return String::from_utf16_le(input.bytes());
|
||||
return String::from_utf16_le_with_replacement_character(input.bytes());
|
||||
}
|
||||
|
||||
ErrorOr<void> Latin1Decoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue