Title Wrong index in tag cleanup
AuthorRodrigo Arias Mallo
CreatedSat, 17 Oct 2026 21:20:16 +0200
State open

After my attempt to fix the wrong usage of the index in Html_tag_cleanup_at_close:

--- a/src/html.cc
+++ b/src/html.cc
@@ -3831,7 +3831,7 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int new_idx)
/* Let these elements close anything left open inside them */
continue;
} else if (Tags[new_idx].Flags & 4 && // Block container
- Tags[stack_idx].Flags & 3) { // Inline element or container
+ Tags[new_idx].Flags & 3) { // Inline element or container
/* Let a block container close inline elements left open inside it. */
continue;
} else {

The new_idx may not be the right index, instead tag_idx should be used.

Reported-by: dogma

Rodrigo Arias Mallo on Sat, 17 Oct 2026 21:24:11 +0200

This test file can exhibit the issue, causing the em and b elements no to auto-close.

<dl>normal <em>italics <b>italics and bold</dl>
(this one should be normal)

Changing new_idx to tag_idx causes them to properly close and display the last text as normal, but this behavior is not what Firefox or Chromium does. We may want to revisit the standard to see what we should do.

In any case, using the new_idx variable as index is wrong.