php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61822 asXML($filename) url-decodes $filename
Submitted: 2012-04-23 02:16 UTC Modified: 2014-07-15 11:53 UTC
Votes:7
Avg. Score:4.0 ± 0.5
Reproduced:7 of 7 (100.0%)
Same Version:0 (0.0%)
Same OS:3 (42.9%)
From: Aldo at WebVyz dot com Assigned:
Status: Verified Package: SimpleXML related
PHP Version: * OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Aldo at WebVyz dot com
New email:
PHP Version: OS:

 

 [2012-04-23 02:16 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-15 11:53 UTC] yohgaki@php.net
-Status: Open +Status: Verified -PHP Version: 5.3.10 +PHP Version: *
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 19:01:26 2019 UTC