Skip to content

ParseAll URL detection dies after the first script and misses mid-tag attributes - #497

Merged
xroche merged 2 commits into
masterfrom
fix-201-203-parser-freeze
Jul 6, 2026
Merged

ParseAll URL detection dies after the first script and misses mid-tag attributes#497
xroche merged 2 commits into
masterfrom
fix-201-203-parser-freeze

Conversation

@xroche

@xroche xroche commented Jul 5, 2026

Copy link
Copy Markdown
Owner

With ParseAll on, URL detection in unknown attributes (data-*, content) died for the rest of the page after the first <script> or <style>: the automaton state is reset on script entry but never on exit, and the dirty parser's character tracker reads it without checking inscript. Even a clean </script> freezes it (its / is fed before the exit branch runs), so this hit nearly every real page; a </script> inside a JS string freezes a quote state instead, and later stray quoted tokens get fetched as phantom URLs. The first commit resets the state at the three script-exit sites.

The second commit fixes the other half: a quoted value only qualified when followed by ),;>/+ or end-of-line, so mid-tag attributes (data-gifsrc="x.gif" data-poster="y.jpg") were undetectable. In a tag outside scripts a value ends at its closing quote, so the follower requirement is waived there, but only for a resolvable attribute name off the no-detect/xmlns lists: review probes showed a plain waiver leaking alt/xmlns values that master suppressed. Adversarial runtime audits are in httrack-works/issue-201-203; each regression test fails on the binary without its fix. Extensionless values stay out of aggressive-parser scope by design.

Closes #201, Closes #203.

The script automaton state (inscript_state_pos) is reset when a script
or style element is entered, but never when it exits. The dirty-parser
character tracker (parseall_lastc) only advances while that state is
INSCRIPT_START, without checking inscript, so whatever state the
automaton holds at </script> freezes for all following HTML. The '/' of
</script> itself is fed to the automaton before the exit branch runs,
so even a clean script deterministically parks it in INSCRIPT_SLASH:
URL detection in unknown attributes (data-*, content) goes dead after
the first script on the page (#201, #203). A </script> inside a JS
string or comment freezes a quote state with parseall_lastc stuck on
'=', turning stray quoted tokens into phantom fetches instead.

Reset the state at the three live exit sites, mirroring the entry
resets. Regression test proven to fail on the unfixed parser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche force-pushed the fix-201-203-parser-freeze branch 2 times, most recently from f1368bc to 50c24c7 Compare July 5, 2026 18:27
Even with the automaton unfrozen, a quoted string only qualified when
its next non-space character was one of ),;>/+ or end-of-line: in HTML
terms, only the last attribute of a tag (or line) could be detected.
The mid-tag attributes of #201 (data-gifsrc="x.gif" data-poster=...)
were structurally unreachable, making detection depend on attribute
order and source formatting.

In a tag outside any script, a quoted value ends at its closing quote,
so waive the follower requirement there. The arm resolves the owning
attribute name itself and declines for no-detect/xmlns names and
non-attribute quotes: the intag_startattr lookup is unreliable mid-tag
(repointed at every in-tag whitespace, stale on glued attributes), and
adversarial review showed a plain intag arm fetching alt/xmlns values
that master suppressed. Script and event-handler contexts keep the
strict gate.

Tests pin each automaton-exit reset (handler fixtures freeze lastc on
';' so they stay live), the nodetect/xmlns bypass shapes, the frozen-
quote phantom-fetch mode, and the '='-resolution decoys. Runtime
audits in httrack-works/issue-201-203/.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche force-pushed the fix-201-203-parser-freeze branch from 50c24c7 to 7eacbba Compare July 5, 2026 21:24
@xroche
xroche merged commit f66ec19 into master Jul 6, 2026
15 checks passed
@xroche
xroche deleted the fix-201-203-parser-freeze branch July 27, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant