netsurf: add TODO on encoding change error code

This commit is contained in:
Pierre Tachoire
2024-01-12 15:26:29 +01:00
parent 0f24660707
commit 2981703b7f
2 changed files with 8 additions and 1 deletions

View File

@@ -1445,6 +1445,13 @@ pub fn documentHTMLParse(reader: anytype, enc: ?[:0]const u8) !*DocumentHTML {
while (ln > 0) { while (ln > 0) {
ln = try reader.read(&buffer); ln = try reader.read(&buffer);
err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln); 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); try parserErr(err);
} }

View File

@@ -119,6 +119,6 @@ test "bug document html parsing #4" {
const file = try std.fs.cwd().openFile("tests/html/bug-html-parsing-4.html", .{}); const file = try std.fs.cwd().openFile("tests/html/bug-html-parsing-4.html", .{});
defer file.close(); defer file.close();
doc = try parser.documentHTMLParse(file.reader(), null); doc = try parser.documentHTMLParse(file.reader(), "UTF-8");
parser.documentHTMLClose(doc) catch {}; parser.documentHTMLClose(doc) catch {};
} }