CURLE_URL_MALFORMAT returned if Location has malformed url #3340
Comments
Thanks for a quick reply. I took 2c5ec33 commit and I can confirm that this doesn't not affect outcome in any way. I still get |
in my case I have a unit test testing invalid urls and I try to fetch them directly and through a redirect to verify that API produces consistent results. Unfortunately with latest libcurl this test now fails |
Another related change from url-api commit: previously if the server replied with corrupt Location that contained spaces ( |
Right, that's a side-effect of the new logic... I don't think we have to do it like this. Care you write up a PR that fixes this? Maybe with a test that verifies it as well?
Please don't append separate problems in the same issue, file it as a separate one. I note that test42 verifies Location following with spaces in the URL so you're probably talking about spaces exactly in the query part? |
Can you help us with a source code to a small application that reproduces this problem and what http response headers it would need to trigger? |
this is the output that I get:
Note, I have a simple HttpServer to be able to simulate whatever I want, you can use whatever you use for that kind of stuff and set Before url-api change res would be OK in second case and I'd be able to retrieve redirect url. |
@pps83 it would be great if you could verify this patch asap as then we might be able to get this merged before the next release, which ships tomorrow morning... |
... when not actually following the redirect. Otherwise we return error for this and an application can't extract the value. Test 1518 added to verify. Reported-by: Pavel Pavlov Fixes #3340
I tried this patch, and all if I apply it all my tests pass as before. |
Thanks for confirming! |
I did this
I do http get using libcurl and returned 302 response intentionally has malformed url in the
Location
header (this is a unit test). I requested libcurl not to follow redirects. libcurl used to always return CURL_OK in this case without checking contents of theLocation
header, but starting from 7.62 unit tests started to fail and it appears that now libcurl returnsCURLE_URL_MALFORMAT
in this case. I think this is wrong, because request actually succeeded and response was received.CURLE_URL_MALFORMAT
means that the request that I made was invalid and had malformed url. Now it's not even clear ifCURLE_URL_MALFORMAT
resulted from the url0 that I requested, or after fetching url0 and checkingLocation
header that contained malformed url1. At least with previous versions of curl I was able to extract value of locations header. It was clear ifCURLE_URL_MALFORMAT
resulted from url0, and I was able to get malformed url1 to inspect/log it. Now I cannot even get the url1.CURLINFO_REDIRECT_URL
returns NULL, andCURLINFO_REDIRECT_COUNT
also returns null.I've seen that url api code added in 7.62, I suspect that now curl tries to validate Location while it was requested not to follow it and effectively fail as it tried to follow the location.
I expected the following
curl/libcurl version
[curl -V output]
operating system
The text was updated successfully, but these errors were encountered: