Skip to content

fix(http): pass no flags to curl_url_set in url_get_host - #6233

Open
Dev-next-gen wants to merge 1 commit into
SunshineStream:masterfrom
Dev-next-gen:fix/url-get-host-flags
Open

Dev-next-gen wants to merge 1 commit into
SunshineStream:masterfrom
Dev-next-gen:fix/url-get-host-flags

Conversation

@Dev-next-gen

Copy link
Copy Markdown
Contributor

Description

http::url_get_host calls curl_url_set(curlu, CURLUPART_URL, url.c_str(), url.length()). The fourth argument of curl_url_set is a flags bitmask, not a length, so the bits of the URL length are read as CURLU_* flags and the parse result depends on how long the URL is.

With libcurl 7.88.1:

input length flags set by the length master this branch
https://[email protected]/a.png 34 CURLU_DISALLOW_USER "" images.igdb.com
https://[email protected]/ab.png 35 CURLU_DISALLOW_USER "" images.igdb.com
images.igdb.com/a.png 21 CURLU_DEFAULT_SCHEME images.igdb.com ""
images.igdb.com/abcd.png 24 none that apply "" ""

/api/covers/upload uses this function to allow only images.igdb.com, so whether a cover URL is accepted depended on its length. The fix passes 0, so every URL is parsed with libcurl's default rules: a URL without a scheme is always rejected, and user info no longer makes a valid URL fail. Full https://images.igdb.com/... URLs, which is what the Web UI sends, return the same host as before.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

Added three cases to UrlGetHostTests in tests/unit/test_httpcommon.cpp: the user info URL and the two schemeless URLs from the table. On master the first two fail.

I could not build test_sunshine here, so the gtest was not run locally; CI will run it. The table above comes from url_get_host copied unchanged from src/httpcommon.cpp on master and on this branch, compiled against libcurl 7.88.1 and called on those inputs. The existing cases (https://images.igdb.com/example.txt, http://localhost:8080, nonsense!!}{::) give the same result on both.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

This pull request was generated by Claude Code, Claude Opus 5.5, low thinking level

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.

The fourth argument of curl_url_set is a flags bitmask, but url_get_host
passed the URL length. Whether a URL parsed therefore depended on its
length: a schemeless URL was accepted only when the length set
CURLU_DEFAULT_SCHEME, and a URL with user info was rejected whenever the
length set CURLU_DISALLOW_USER.
@Dev-next-gen

Copy link
Copy Markdown
Contributor Author

This pull request was generated by Claude Code, Claude Opus 5.5, low thinking level

@sonarqubecloud

sonarqubecloud Bot commented Dec 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant