From fc0534ea26bfecc6fecc0e0a75104dc39d5a86f1 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 13 May 2026 09:43:01 +0100 Subject: [PATCH] ensure mode is always set to INITIAL during startTokenization While currently, all branches set a mode, this is both subtle and fragile; if a branch ends up not setting mode it will never be reset. This means subsequent calls to start tokenisation can end up with a different initial mode. This change simply resets mode to INITIAL on every startTokenization() call, ensuring that if we ever miss it, it will be reset. --- src/nu/validator/htmlparser/impl/TreeBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nu/validator/htmlparser/impl/TreeBuilder.java b/src/nu/validator/htmlparser/impl/TreeBuilder.java index e17c3a04..f2d92592 100644 --- a/src/nu/validator/htmlparser/impl/TreeBuilder.java +++ b/src/nu/validator/htmlparser/impl/TreeBuilder.java @@ -592,6 +592,7 @@ public boolean dropBufferIfLongerThan(int length) { templateModeStack = new int[64]; listOfActiveFormattingElements = new StackNode[64]; needToDropLF = false; + mode = INITIAL; originalMode = INITIAL; templateModePtr = -1; stackNodesIdx = 0;