diff --git a/src/netsurf.zig b/src/netsurf.zig index b24c5d26..dca13979 100644 --- a/src/netsurf.zig +++ b/src/netsurf.zig @@ -1445,6 +1445,13 @@ pub fn documentHTMLParse(reader: anytype, enc: ?[:0]const u8) !*DocumentHTML { while (ln > 0) { ln = try reader.read(&buffer); err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln); + // TODO handle encoding change error return. + // When the HTML contains a META tag with a different encoding than the + // original one, a c.DOM_HUBBUB_HUBBUB_ERR_ENCODINGCHANGE error is + // returned. + // In this case, we must restart the parsing with the new detected + // encoding. The detected encoding is stored in the document and we can + // get it with documentGetInputEncoding(). try parserErr(err); } diff --git a/src/run_tests.zig b/src/run_tests.zig index 8369ec61..1ba0f8b3 100644 --- a/src/run_tests.zig +++ b/src/run_tests.zig @@ -119,6 +119,6 @@ test "bug document html parsing #4" { const file = try std.fs.cwd().openFile("tests/html/bug-html-parsing-4.html", .{}); defer file.close(); - doc = try parser.documentHTMLParse(file.reader(), null); + doc = try parser.documentHTMLParse(file.reader(), "UTF-8"); parser.documentHTMLClose(doc) catch {}; }