Skip to content

getinfo: clarify invalid URL handling for CURLINFO_EFFECTIVE_URL - #23444

Closed
mszabo-wikia wants to merge 1 commit into
curl:masterfrom
mszabo-wikia:doc-effective-url
Closed

mszabo-wikia wants to merge 1 commit into
curl:masterfrom
mszabo-wikia:doc-effective-url

Conversation

@mszabo-wikia

Copy link
Copy Markdown
Contributor

Since 7a6bd02 CURLINFO_EFFECTIVE_URL returns CURLE_OUT_OF_MEMORY if the effective URL couldn't be parsed, which surprised some code that expected it to be mostly always present in normal operation (we interact with libcurl over HHVM's wrapper, which, akin to PHP, wraps[1] easy_getinfo and returns a dict with optional entries, so it's been easy for things to assume that url would always be set).

Clarify the new behaviour in docs and have CURLINFO_EFFECTIVE_URL return the relevant parsing error code rather than CURLE_OUT_OF_MEMORY for invalid URLs.

[1] https://github.com/facebook/hhvm/blob/c83584cad90cc9327d0b75175135d46882d8dc1f/hphp/runtime/ext/curl/ext_curl.cpp#L208

Comment thread lib/getinfo.c

if(uc || !url)
return CURLE_OUT_OF_MEMORY;
return uc ? Curl_uc_to_curlcode(uc) : CURLE_OUT_OF_MEMORY;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm admittedly not 100% certain about whether to change the return code here, happy to leave it as-is and just keep the docfix

@github-actions github-actions Bot added the tests label Oct 16, 2026
Since 7a6bd02 `CURLINFO_EFFECTIVE_URL` returns `CURLE_OUT_OF_MEMORY`
if the effective URL couldn't be parsed, which surprised some code
that expected it to be mostly always present in normal operation
(we interact with `libcurl` over HHVM's wrapper, which, akin to PHP,
wraps[1] easy_getinfo and returns a dict with optional entries,
so it's been easy for things to assume that `url` would always be set).

Clarify the new behaviour in docs and have `CURLINFO_EFFECTIVE_URL` return
the relevant parsing error code rather than `CURLE_OUT_OF_MEMORY`
for invalid URLs.

[1] https://github.com/facebook/hhvm/blob/c83584cad90cc9327d0b75175135d46882d8dc1f/hphp/runtime/ext/curl/ext_curl.cpp#L208
Comment thread tests/libtest/lib1990.c Dismissed

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.

🟢 Approval recommended

The localized changes include matching documentation and regression coverage, with no identified blocking issues.

No open issues 🎉

What changed in this PR

Clarifies how libcurl reports invalid effective URLs while preventing unfiltered URLs from being returned on failure.

Changes:

  • Returns the relevant URL parsing error and sets the output pointer to NULL.
  • Documents credential removal and empty or invalid URL behavior.
  • Adds regression coverage for unused handles and malformed URLs containing credentials.
File Description
tests/​libtest/​Makefile.inc Registers the new test source.
tests/​libtest/​lib1990.c Exercises empty and malformed effective URLs.
tests/​data/​test1990 Defines expected output and error codes.
tests/​data/​Makefile.am Registers the test case.
lib/​getinfo.c Corrects error mapping and output-pointer handling.
docs/​libcurl/​opts/​CURLINFO_EFFECTIVE_URL.md Documents effective URL return behavior.

Review effort: Balanced

@bagder bagder closed this in 589c35f Oct 17, 2026
@bagder

bagder commented Oct 17, 2026

Copy link
Copy Markdown
Member

Thanks!

@mszabo-wikia

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review!

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

Labels

Development

Successfully merging this pull request may close these issues.

4 participants