php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43411 parse_url with relative URLs contained http:// in parameters
Submitted: 2007-11-26 12:34 UTC Modified: 2007-11-26 12:49 UTC
From: php at koterov dot ru Assigned:
Status: Not a bug Package: URL related
PHP Version: 5.2.5 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at koterov dot ru
New email:
PHP Version: OS:

 

 [2007-11-26 12:34 UTC] php at koterov dot ru
Description:
------------
When I pass a relative URL to parse_url and it contains something like "http://xxx" in QUERY_STRING parameters, parse_url reports that the URL is broken.

So it is not always safe to call 
parse_url($_SERVER['REQUEST_URI'])

I think the solution should be: if an URL is relative (started with '/'), do not report a warning when its arguments contain ":".

Possibly you will say "won't fix" and "URL is not RFC-complaint", but this argument is not relevant when I call parse_url($_SERVER['REQUEST_URI']) (it may be hand-made and non-RFC complaint).

Reproduce code:
---------------
print_r(parse_url('/test/?retpath=http://xxx'));

Expected result:
----------------
ok

Actual result:
--------------
Warning: parse_url(/test/?retpath=http://xxx): Unable to parse URL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-26 12:49 UTC] jani@php.net
There is quite clear note in manual for parse_url(): "Note: This function doesn't work with relative URLs."
 [2013-05-15 18:45 UTC] alias dot mac at gmail dot com
Jani,

It is working on 5.3.20.
Example:

<?php

$x = 'http://example.com/path/to/somewhere?
param1=x&param2=http://another.example.com/path/to/another/example/';

var_dump(parse_url($x));

$y = '/path/to/somewhere?
param1=x&param2=http://another.example.com/path/to/another/example/';

var_dump(parse_url($y));
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC