Bug #61822 [Opn->Ver]: asXML($filename) url-decodes $filename
| From: | yohgaki@php.net | Date: | Tue, 15 Jul 2014 11:53:31 +0000 |
| Subject: | Bug #61822 [Opn->Ver]: asXML($filename) url-decodes $filename | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186628@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61822&edit=1
ID: 61822
Updated by: yohgaki@php.net
Reported by: Aldo at WebVyz dot com
Summary: asXML($filename) url-decodes $filename
-Status: Open
+Status: Verified
Type: Bug
Package: SimpleXML related
Operating System: Linux
-PHP Version: 5.3.10
+PHP Version: *
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2012-04-23 02:16:46] Aldo at WebVyz dot com
Description:
------------
I was saving a SimpleXML object and kept getting errors that the file could not be written. Upon
further examination, I discovered that the directory containg an url-encoded slash (%2F) and while
the directory existed as an encoded string (e.g. 'dir1%2Fdir2/file.xml') asXML was
explicitly unencoding it and attempting to write to a different directory (which does not exist,
e.g. 'dir1/dir2.xml'). No amounts of double-encoding the filename succeeded in creating
the file successfully (same error) so I had to resort to
file_put_contents("{$dirname}/file.xml", $sXML->saveXML());
Test script:
---------------
$sXML = new SimpleXMLElement('<result />');
$filename = 'dir1%2Fdir2/result.xml';
mkdir(dirname($filename));
file_put_contents($filename, $sXML->asXML()); // works as expected
$sXML->asXML($filename); // fails; no such file/directory
Expected result:
----------------
Filename arguments given to asXML should be accepted without url-decoding
Actual result:
--------------
filenames are being url-decoded, which is not what I want or expect
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61822&edit=1