Edit report at https://bugs.php.net/bug.php?id=64754&edit=1
ID: 64754
Comment by: cmbecker69 at gmx dot de
Reported by: jia dot cheng dot wu at gmail dot com
Summary: pathinfo bug handling extra "."
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: WINDOWS 7
PHP Version: 5.3.24
Block user comment: N
Private report: N
New Comment:
pathinfo() is meant to return information about a *file path*,
not an URL. The latter can be accomplished with parse_url().
Furthermore the documentation states:
| If the path has more than one an extension,
| PATHINFO_EXTENSION returns only the last one
| and PATHINFO_FILENAME only strips the last one.
| (see first example below).
According to that the actual result is correct.
Previous Comments:
------------------------------------------------------------------------
[2013-05-07 19:13:24] mail+php at requinix dot net
pathinfo() is for filenames. Use parse_url() for URLs.
------------------------------------------------------------------------
[2013-05-02 05:45:38] jia dot cheng dot wu at gmail dot com
Description:
------------
Array returned by function pathinfo() contains wrong values when extra "." is
introduced in the parameter, even though "." is a valid character of a query
string.
Test script:
---------------
<php?
$test_url = "/test.php?q=".urlencode("hello this is a test 1.0");
echo "test_url:".$test_url.PHP_EOL;
var_dump(pathinfo($test_url));
?>
Expected result:
----------------
test_url:/test.php?q=hello+this+is+a+test+1.0
array(4) {
["dirname"]=>
string(1) "\"
["basename"]=>
string(35) "test.php?q=hello+this+is+a+test+1.0"
["extension"]=>
string(26) "q=hello+this+is+a+test+1.0"
["filename"]=>
string(4) "test"
}
Actual result:
--------------
test_url:/test.php?q=hello+this+is+a+test+1.0
array(4) {
["dirname"]=>
string(1) "\"
["basename"]=>
string(35) "test.php?q=hello+this+is+a+test+1.0"
["extension"]=>
string(1) "0"
["filename"]=>
string(33) "test.php?q=hello+this+is+a+test+1"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64754&edit=1