Repository navigation
Conversation
Setting CURLUPART_HOST to "[fe80::1%25eth0]" without CURLU_URLENCODE checked a decoded copy of the host, which moved the zone id into u->zoneid, but then stored the original string with the zone still in it. Getting CURLUPART_URL then appended the zone id again and returned "[fe80::1%25eth0%25eth0]", which does not parse back. Store the checked and normalized address instead, the same form a parsed URL gets. Extend test 1560 to verify.
bagder
approved these changes
Oct 24, 2026
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix preserves buffer ownership, separates the address from its zone ID, and includes regression coverage for both affected operations.
No open issues 🎉
What changed in this PR
This PR fixes duplicate IPv6 zone IDs when setting a host through the URL API, making host storage consistent with full-URL parsing.
Changes:
- Store the validated, normalized IPv6 address separately from its zone ID.
- Add regression cases for setting a host with a zone ID and then clearing the zone ID.
| File | Description |
|---|---|
| tests/libtest/lib1560.c | Adds regression coverage for zone-ID handling when setting hosts. |
| lib/urlapi.c | Stores the normalized IPv6 host to prevent duplicate zone IDs. |
Review effort: Balanced
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting an IPv6 host with a zone id gives a URL with the zone in it twice:
The output does not parse back. Without CURLU_URLENCODE,
url_sethost()checks a decoded copy of the host. That check pulls the zone out intou->zoneid, but the original string with the zone still in it is what gets stored, andurlget_url()then appendsu->zoneidagain. This stores the checked address instead, so the host part is[fe80::1]with the zone kept separately, the same as when the whole URL is parsed. One side effect: the address is now normalized the way a parsed URL already is (for example[FE80::0:1]becomes[fe80::1]).I added two set_parts cases to lib1560.c (the plain one fails before and passes after), and the URL and IPv6 tests still pass locally.
I found this with an AI-assisted code review and then checked it by hand on a local build.