Skip to content

urlapi: URL decode hostname before IP address normalization#21918

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/urlencoded-ipnum
Closed

urlapi: URL decode hostname before IP address normalization#21918
bagder wants to merge 1 commit into
masterfrom
bagder/urlencoded-ipnum

Conversation

@bagder

@bagder bagder commented Jun 9, 2026

Copy link
Copy Markdown
Member

With this, IPv6 addresses that end with '%25' with no following zone id are considered invalid.

Extend test 1560 to verify

Reported-by: Hem Parekh

With this, IPv6 addresses that end with '%25' with no following zone id are
considered invalid.

Extend test 1560 to verify

Reported-by: Hem Parekh
@bagder bagder added the URL label Jun 9, 2026
@github-actions github-actions Bot added the tests label Jun 9, 2026
@bagder bagder marked this pull request as ready for review June 9, 2026 06:31
@bagder bagder requested a review from Copilot June 9, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates curl’s URL parser to URL-decode the hostname earlier in authority parsing, so that percent-encoded IP literals (notably IPv6) are decoded before IP address normalization/validation. This makes bracketed IPv6 addresses ending in %25 with no following zone id be treated as invalid, and adds/adjusts unit tests to cover these cases.

Changes:

  • Decode the authority host earlier (before IPv4/IPv6 normalization) in parse_authority().
  • Extend URL parsing tests to cover percent-encoded IPv4/IPv6 address forms and invalid zone-id edge cases.
  • Update expected behavior so bracketed IPv6 ending with %25 and no zone id is rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/urlapi.c Decodes host before IP normalization so percent-encoded IP literals are validated correctly (including IPv6 zone-id edge cases).
tests/libtest/lib1560.c Adds/updates URL parsing test vectors for percent-encoded IP literals and invalid IPv6 zone-id cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/libtest/lib1560.c
@bagder bagder closed this in 04afd16 Jun 9, 2026
@bagder bagder deleted the bagder/urlencoded-ipnum branch June 9, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants