Requests icon indicating copy to clipboard operation
Requests copied to clipboard

URL reformatting issue with Requests_IRI

Open mauricesvay opened this issue 12 years ago • 2 comments

When requesting an URL with a fragment, the reformatted URL can be different from the original one. The following example rewrites https://example.com/#foobar to https://example.com#foobar instead of returning the same URL. As a consequence, curl fails to load the URL.

$url = "https://example.com/#foobar";
$iri = new Requests_IRI($url);
$url = $iri->uri;
var_dump($url);

mauricesvay avatar Jul 11 '13 19:07 mauricesvay

The IRI parser is intended to return a different IRI, or rather, the "normalised" version of it. The effect you're seeing here is the root path (/) being translated to an empty path. There are in fact tests for this behaviour, so it is intentional.

However, maybe cURL needs correcting for this. Keep in mind that fragments are a client-side behaviour, and shouldn't be getting passed through at all (which I suspect is the real bug here).

rmccue avatar Jul 12 '13 03:07 rmccue

Action plan:

  1. Create a test case to proof or disproof that there is a bug.
  2. If a failing test can be created: fix the bug.
  3. Otherwise close this ticket.

Additionally @schlessera will check the URL specs to verify whether passing #fragment should be handled or not.

jrfnl avatar Feb 28 '22 19:02 jrfnl