urlapi: make dedotdotify handle leading dots correctly#20974
Closed
urlapi: make dedotdotify handle leading dots correctly#20974
Conversation
Paths starting with one or two leading dots but without a following slash were not handled correctly. Follow-up to c31dd66 Extended test 1395 accordingly with a set of new test string. Reported by Codex Security
There was a problem hiding this comment.
Pull request overview
Expands coverage for URL path “remove dot segments” behavior (RFC 3986 §5.2.4) and adjusts dedotdotify() to avoid stripping a leading dot (. / %2e) unless it forms a complete dot-segment (e.g., ./, ../, . end, .. end).
Changes:
- Add new unit test vectors for tricky prefixes (percent-encoded sequences, multiple slashes, “well-known” variants, and partial percent-escapes).
- Update
dedotdotify()to restore the original input when an initial./%2ematch does not represent a complete dot-segment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/unit/unit1395.c | Adds additional dedotdotify() test cases covering edge cases and regressions. |
| lib/urlapi.c | Refines initial dot-segment handling by restoring original input when the leading dot match is not a full segment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
Paths starting with one or two leading dots but without a following slash were not handled correctly.
Follow-up to c31dd66
Extended test 1395 accordingly with a set of new test string.
Reported by Codex Security