Skip to content

Keep :80 in a URL path or query - #2101

Open
xroche wants to merge 4 commits into
masterfrom
fz/B2
Open

xroche wants to merge 4 commits into
masterfrom
fz/B2

Conversation

@xroche

@xroche xroche commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

jump_toport_const now looks for the port only in the URL's authority, before the first /, ? or #. Before, the parser's default-port strip removed a :80 from the path or the query, so http://h/x:80 became http://h/x and ?u=1:80 became ?u=1.

The function is exported (HTSEXT_API), so its behaviour changes for library users. It now returns NULL for http://h/x:80, and it now finds the port in http://h:80?x], where the old search for ] hid it. The other in-tree callers pass a bare host and see no change, and hts_wizard_host_scope and the proxy code ignore a port found before the host.

Test 393 and the stripport self-test fail on master and pass here. Against master, tools/parser-diff.sh shows only the path and query links added to absolute.html changing.

xroche and others added 4 commits November 7, 2026 18:46
jump_toport_const() scanned for ':' past the authority, so the parser's
default-port strip turned http://h/x:80 into http://h/x and ?u=1:80 into
?u=1. A ']' in the query with no '/' also hid a real authority port.
Bound both scans to the authority, which lets the wizard drop its own
bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
An '@' in the query or fragment moved the port search past the '?', so
http://h?u=a@b:80 still lost its ':80'. Bound the userinfo search by the
authority end inside jump_toport_const.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
dc37788 bounded the userinfo '@' search in jump_toport_const by '/?#'
while jump_identification_const bounds it by '/' only. A '?' or '#' in
the userinfo then put the port before the host, and the wizard scope
walk read out of bounds on u:p?w@foo.com:81.

Start the port search at the identified host again and bound it there,
so the two always agree. The wizard and the proxy paths also treat a
port before the host as no port.

An '@' in a query (http://h?u=a@b:80) is read as userinfo again, as on
master: the engine connects to b:80, and the port now says the same.

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