From fcf6f084756627cb49ad65999fe3718fd5d19078 Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Mon, 27 Jul 2026 05:08:18 +0200 Subject: [PATCH] treebuilder: treat and as void elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libhubbub predates the HTML5 / elements, so they were absent from the gperf element-type wordlist. element_type_from_name returned UNKNOWN for them and the "any other start tag" path pushed onto the open-elements stack as a non-void container — the following then nested inside the instead of becoming its sibling under . In the standard `` order (sources first, fallback img last) a downstream consumer that ignores never sees the , dropping the picture entirely. Add both to the wordlist so the generated perfect hash knows them (which also makes element_type_to_name answer for them), and add them to the void-element branch so they insert without being pushed. Co-Authored-By: Claude Opus 4.8 Signed-off-by: Cyril Hrubis --- src/treebuilder/element-type.gperf | 2 ++ src/treebuilder/element-type.h | 4 ++-- src/treebuilder/in_body.c | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/treebuilder/element-type.gperf b/src/treebuilder/element-type.gperf index c0980d3..10b93da 100644 --- a/src/treebuilder/element-type.gperf +++ b/src/treebuilder/element-type.gperf @@ -110,6 +110,7 @@ s, S script, SCRIPT select, SELECT small, SMALL +source, SOURCE spacer, SPACER strike, STRIKE strong, STRONG @@ -125,6 +126,7 @@ th, TH thead, THEAD title, TITLE tr, TR +track, TRACK tt, TT u, U ul, UL diff --git a/src/treebuilder/element-type.h b/src/treebuilder/element-type.h index 75612fd..02a396e 100644 --- a/src/treebuilder/element-type.h +++ b/src/treebuilder/element-type.h @@ -20,8 +20,8 @@ typedef enum FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HR, IFRAME, IMAGE, IMG, INPUT, ISINDEX, LI, LINK, LISTING, MAIN, MENU, META, NAV, NOEMBED, NOFRAMES, NOSCRIPT, OL, OPTGROUP, OPTION, P, PARAM, PLAINTEXT, - PRE, SCRIPT, SECTION, SELECT, SPACER, STYLE, SUMMARY, TBODY, TEXTAREA, - TFOOT, THEAD, TITLE, TR, UL, WBR, + PRE, SCRIPT, SECTION, SELECT, SOURCE, SPACER, STYLE, SUMMARY, TBODY, + TEXTAREA, TFOOT, THEAD, TITLE, TR, TRACK, UL, WBR, /* Scoping */ APPLET, BUTTON, CAPTION, HTML, MARQUEE, OBJECT, TABLE, TD, TH, /* Formatting */ diff --git a/src/treebuilder/in_body.c b/src/treebuilder/in_body.c index 0e4184c..765ea38 100644 --- a/src/treebuilder/in_body.c +++ b/src/treebuilder/in_body.c @@ -322,10 +322,11 @@ hubbub_error process_start_tag(hubbub_treebuilder *treebuilder, current_table(treebuilder)].tainted = false; treebuilder->context.mode = IN_TABLE; } - } else if (type == AREA || type == BASEFONT || - type == BGSOUND || type == BR || + } else if (type == AREA || type == BASEFONT || + type == BGSOUND || type == BR || type == EMBED || type == IMG || type == INPUT || - type == PARAM || type == SPACER || type == WBR) { + type == PARAM || type == SOURCE || type == SPACER || + type == TRACK || type == WBR) { err = reconstruct_active_formatting_list(treebuilder); if (err != HUBBUB_OK) return err;