urlapi: verify the last letter of a scheme when set explictly#20893
Closed
urlapi: verify the last letter of a scheme when set explictly#20893
Conversation
A logic error made the function not check the last character, which thus could make it accept invalid schemes. Added test 1965 to verify Reported-by: Otis Cui Lei
There was a problem hiding this comment.
Pull request overview
Fixes a URL API scheme-validation bug where the last character of an explicitly set (non-built-in) scheme was not validated, which could allow invalid schemes to be accepted. Adds a new libtest + testcase to cover a matrix of valid/invalid scheme strings and maximum-length behavior.
Changes:
- Fix
set_url_scheme()validation to correctly check the final character of custom schemes. - Add new libtest
lib1965that exercisescurl_url_set(CURLUPART_SCHEME, ...)with various scheme strings. - Register the new test in the libtest and tests/data build/test lists.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/urlapi.c |
Fixes scheme-validation loop to include the last character. |
tests/libtest/lib1965.c |
New libtest that prints ACCEPTED/REJECTED for a list of schemes. |
tests/libtest/Makefile.inc |
Adds lib1965.c to the libtest build. |
tests/data/test1965 |
New testcase verifying expected stdout from lib1965. |
tests/data/Makefile.am |
Registers test1965 in the testcases list. |
💡 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.
A logic error made the function not check the last character, which thus could make it accept invalid schemes.
Added test 1965 to verify
Reported-by: Otis Cui Lei