LibWeb+LibXML: Make Listener::set_source(ByteString) fallible

`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
parent 2397ae4af5
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

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">À¯õ</svg>

After

Width:  |  Height:  |  Size: 74 B

View file

@ -0,0 +1 @@
PASS (didn't crash)

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="../data/invalid_utf8_corrupt.svg" type="image/svg+xml">
</head>
<script src="include.js"></script>
<script>
test(() => {
println("PASS (didn't crash)")
});
</script>
</html>