php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64754 pathinfo bug handling extra "."
Submitted: 2013-05-02 05:45 UTC Modified: 2013-06-19 06:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jia dot cheng dot wu at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.24 OS: WINDOWS 7
Private report: No CVE-ID: None
 [2013-05-02 05:45 UTC] 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"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-07 19:13 UTC] mail+php at requinix dot net
pathinfo() is for filenames. Use parse_url() for URLs.
 [2013-05-18 16:00 UTC] cmbecker69 at gmx dot de
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.
 [2013-06-19 06:58 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2013-06-19 06:58 UTC] ab@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

as per previous answers
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 08:01:30 2024 UTC