mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibTextCodec: Change UTF-8's decoder to replace invalid code points
The UTF-8 decoder will currently crash if it is provided invalid UTF-8 input. Instead, change its behavior to match that of all other decoders to replace invalid code points with U+FFFD. This is required by the web.
This commit is contained in:
parent
cb32bb3502
commit
00fa23237a
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/00fa23237a Pull-request: https://github.com/SerenityOS/serenity/pull/18772 Issue: https://github.com/SerenityOS/serenity/issues/18432
1 changed files with 6 additions and 4 deletions
|
@ -213,10 +213,12 @@ ErrorOr<String> convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte
|
|||
|
||||
VERIFY(actual_decoder);
|
||||
|
||||
// FIXME: 3. Process a queue with an instance of encoding’s decoder, ioQueue, output, and "replacement".
|
||||
// This isn't the exact same as the spec, especially the error mode of "replacement", which we don't have the concept of yet.
|
||||
// 3. Process a queue with an instance of encoding’s decoder, ioQueue, output, and "replacement".
|
||||
// FIXME: This isn't the exact same as the spec, which is written in terms of I/O queues.
|
||||
auto output = TRY(actual_decoder->to_utf8(input));
|
||||
|
||||
// 4. Return output.
|
||||
return actual_decoder->to_utf8(input);
|
||||
return output;
|
||||
}
|
||||
|
||||
ErrorOr<String> Decoder::to_utf8(StringView input)
|
||||
|
@ -242,7 +244,7 @@ ErrorOr<String> UTF8Decoder::to_utf8(StringView input)
|
|||
bomless_input = input.substring_view(3);
|
||||
}
|
||||
|
||||
return String::from_utf8(bomless_input);
|
||||
return Decoder::to_utf8(bomless_input);
|
||||
}
|
||||
|
||||
ErrorOr<void> UTF16BEDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
||||
|
|
Loading…
Reference in a new issue