urlapi: consume trailing dots after IPv4 numerical addresses#21635
Closed
bagder wants to merge 3 commits into
Closed
urlapi: consume trailing dots after IPv4 numerical addresses#21635bagder wants to merge 3 commits into
bagder wants to merge 3 commits into
Conversation
If the hostname is specified as an IPv4 numerical address and it is followed by a single dot, acccept that as a valid IPv4 and remove the dot when normalizing. This prevents otherwise legitimate IPv4 hostnames to have trailing dots. Seems to match what browsers do. Extended test 1560 to verify.
There was a problem hiding this comment.
Pull request overview
Allows a single trailing dot after IPv4 numerical addresses in URLs and normalizes them by stripping the dot, matching browser behavior. Previously, such inputs were left unchanged (e.g., 0111.02.0x3. was kept as-is instead of being normalized to 73.2.0.3).
Changes:
- In
ipv4_normalize(), when number parsing returnsSTRE_NO_NUMand we're at end-of-string after at least one part was parsed, the trailing empty part is consumed (n--) rather than rejected. - When the 4th part is followed by a single trailing
.with nothing after it, parsing completes successfully instead of failing. - Updated two existing test cases (no longer keep trailing dot) and added 11 new test cases covering various IPv4 trailing-dot scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/urlapi.c | Modify ipv4_normalize() to accept and swallow a single trailing dot after numerical IPv4 addresses; update docstring. |
| tests/libtest/lib1560.c | Update two existing expected outputs and add tests covering trailing-dot IPv4 normalization and rejection of double trailing dots. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
outcast36
pushed a commit
to greearb/curl
that referenced
this pull request
Jun 3, 2026
If the hostname is specified as an IPv4 numerical address and it is followed by a single dot, acccept that as a valid IPv4 and remove the dot when normalizing. This prevents otherwise legitimate IPv4 hostnames to have trailing dots. Seems to match what browsers do. Extended test 1560 to verify. Closes curl#21635
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.
If the hostname is specified as an IPv4 numerical address and it is followed by a single dot, acccept that as a valid IPv4 and remove the dot when normalizing.
This prevents otherwise legitimate IPv4 hostnames to have trailing dots. Seems to match what browsers do.
Extended test 1560 to verify.