From: hanskrentel at yahoo dot de
Operating system: Windows
PHP version: 5.4.9
Package: Streams related
Bug Type: Bug
Bug description:file:// protocol does not support percent-encoded characters
Description:
------------
Using a file-URI containing characters that are percent-encoded (one
byte/octet
is encoded as a character triplet, e.g. Space -> %20) do not work. The URI
is
not properly decoded.
Consider the following file on disk:
c:\temp\catalog 2.xml
PHP is able to find it existing via:
is_file('file:///C:/temp/catalog 2.xml');
However, commonly that file is written as:
file:///C:/temp/catalog%202.xml
And using that filename in PHP via:
is_file('file:///C:/temp/catalog%202.xml');
gives FALSE.
(Example is a libxml catalog file, properly specified for libxml)
When you're looking into this, it might be worth to also look for + as
encoding
for space - just not that this case gets overlooked.
Test script:
---------------
<?php
touch($name = 'catalog 2.xml');
$uri = sprintf('file:///%s/%s', strtr(__DIR__, ['\\' => '/', ' ' =>
'%20']), rawurlencode($name));
printf('%s - %s (%d)', is_file($uri) ? 'OK' : 'FAIL', $uri, unlink($name));
Expected result:
----------------
OK - file:///C:/temp/catalog%202.xml (1)
Actual result:
--------------
FAIL - file:///C:/temp/catalog%202.xml (1)
--
Edit bug report at https://bugs.php.net/bug.php?id=63769&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63769&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63769&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63769&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63769&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63769&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63769&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63769&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63769&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63769&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63769&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63769&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63769&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63769&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63769&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63769&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63769&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63769&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63769&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63769&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63769&r=mysqlcfg