Skip to content

urlapi: verify the last letter of a scheme when set explictly#20893

Closed
bagder wants to merge 2 commits intomasterfrom
bagder/url-set-scheme
Closed

urlapi: verify the last letter of a scheme when set explictly#20893
bagder wants to merge 2 commits intomasterfrom
bagder/url-set-scheme

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Mar 11, 2026

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

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
@bagder bagder marked this pull request as ready for review March 11, 2026 22:16
@bagder bagder requested a review from Copilot March 11, 2026 22:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 lib1965 that exercises curl_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.

Comment thread tests/libtest/lib1965.c
@bagder bagder closed this in 11c14b5 Mar 11, 2026
@bagder bagder deleted the bagder/url-set-scheme branch March 11, 2026 22:49
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