LibWeb+LibXML: Make Listener::set_source(ByteString) fallible
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

`set_source` takes a ByteString but the implementation might require a
specific encoding. Make it fallible so that we don't need to crash in
the case of invalid UTF-8 or similar.

The test includes a sequence of invalid UTF-8 bytes that crash the
browser without this change.
This commit is contained in:
rmg-x 2025-09-30 10:53:41 -05:00 committed by Ali Mohammad Pur
commit b9554038ff
Notes: github-actions[bot] 2025-10-02 00:27:16 +00:00
7 changed files with 25 additions and 5 deletions

View file

@ -62,9 +62,10 @@ XMLDocumentBuilder::XMLDocumentBuilder(DOM::Document& document, XMLScriptingSupp
m_namespace_stack.append({ {}, 1 });
}
void XMLDocumentBuilder::set_source(ByteString source)
ErrorOr<void> XMLDocumentBuilder::set_source(ByteString source)
{
m_document->set_source(MUST(String::from_byte_string(source)));
m_document->set_source(TRY(String::from_byte_string(source)));
return {};
}
void XMLDocumentBuilder::set_doctype(XML::Doctype doctype)