Skip to content

urlapi: make curl_url_dup() copy the guessed_scheme flag - #23043

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/url-dup-guessed
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/url-dup-guessed

Conversation

@bagder

@bagder bagder commented Sep 22, 2026

Copy link
Copy Markdown
Member

curl_url_dup() copied port_present, fragment_present and query_present but missed guessed_scheme, so a duplicated handle always reported an explicit scheme. Applications relying on CURLU_GUESS_SCHEME plus CURLU_NO_GUESS_SCHEME to reject bare hostnames after duplicating a handle would silently accept them instead.

Verified in test 1989

Reported-by: Joshua Rogers

curl_url_dup() copied port_present, fragment_present and query_present
but missed guessed_scheme, so a duplicated handle always reported an
explicit scheme. Applications relying on CURLU_GUESS_SCHEME plus
CURLU_NO_GUESS_SCHEME to reject bare hostnames after duplicating a
handle would silently accept them instead.

Verified in test 1989

Reported-by: Joshua Rogers
@github-actions github-actions Bot added the tests label Sep 22, 2026
@bagder
bagder marked this pull request as ready for review September 22, 2026 14:41
@bagder
bagder requested a balanced review from Copilot September 22, 2026 14:41

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.

Copilot review overview

🟢 Approval recommended

The focused fix correctly preserves URL state and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Ensures duplicated URL handles retain whether their scheme was guessed.

Changes:

  • Copies guessed_scheme in curl_url_dup().
  • Adds and registers regression test 1989.
File Description
lib/​urlapi.c Preserves the guessed-scheme flag during duplication.
tests/​libtest/​lib1989.c Tests duplication behavior.
tests/​libtest/​Makefile.inc Registers the libtest source.
tests/​data/​test1989 Defines the regression test case.
tests/​data/​Makefile.am Registers test 1989.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder bagder closed this in 13e84a6 Sep 22, 2026
@bagder
bagder deleted the bagder/url-dup-guessed branch September 22, 2026 21:29
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.

3 participants