Skip to content

Percent-encode quotes and angle brackets in the links the parser writes - #2103

Open
xroche wants to merge 3 commits into
masterfrom
fz/B1
Open

xroche wants to merge 3 commits into
masterfrom
fz/B1

Conversation

@xroche

@xroche xroche commented Nov 7, 2026

Copy link
Copy Markdown
Owner

The parser now percent-encodes ", ', < and > in the host and path of the absolute links it writes. This covers -K, -K3, -K5, external links, the ?link= of -x and applet code=. Before, a link to a&quot;onmouseover=... came out with a raw ", which closed the href and made the rest of the URL an attribute.

Relative links were already safe, and & still comes out as &amp;. On every tools/parser-diff.sh leg, only links holding those four characters differ from origin/master (its --self-check passes). Test 768 fails on origin/master, and it fails again when any one of 7 writer sites is reverted. The 8th site sits in a branch that never runs.

xroche and others added 3 commits November 7, 2026 19:30
The absolute writers (-K, -K3, -K5, external links, -x's ?link= and applet
code=) copied the host and path through an escaper that only handles &,
so a link to a&quot;onmouseover=... came out with a raw " that closed
the attribute. They now percent-encode " ' < > as well, also inside a
script, where the HTML escaper is skipped.

Test 768 crawls a fixture under the default, -K, -K3 and -x options.
A corpus line in tools/parser-corpus/absolute.html lets parser-diff see
the change on its legs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
HT_ADD_URL_HTMLESCAPED also turns & into &amp;, HT_ADD_URL_PCTQUOTES
leaves it raw. The applet codebase and code values now go through the
html variant, so a raw & no longer reaches those attributes.

Test 768 now covers a quote in the host, the applet codebase and code
values, and a script string under -K and -K3, which keeps & raw. The
fixtures join EXTRA_DIST so distcheck ships them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche enabled auto-merge (squash) November 7, 2026 19: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

Development

Successfully merging this pull request may close these issues.

1 participant