Edit report at https://bugs.php.net/bug.php?id=43411&edit=1

 ID:                 43411
 Comment by:         alias dot mac at gmail dot com
 Reported by:        php at koterov dot ru
 Summary:            parse_url with relative URLs contained http:// in
                     parameters
 Status:             Not a bug
 Type:               Bug
 Package:            URL related
 PHP Version:        5.2.5
 Block user comment: N
 Private report:     N

 New Comment:

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));


Previous Comments:
------------------------------------------------------------------------
[2007-11-26 12:49:18] j...@php.net

There is quite clear note in manual for parse_url(): "Note: This function 
doesn't work with relative URLs."

------------------------------------------------------------------------
[2007-11-26 12:34:59] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=43411&edit=1

Reply via email to