Bug #61469 [Opn->Nab]: simplexml_load_file() url encodes file names if they use a stream wrapper

From: Date: Fri, 23 Mar 2012 12:33:43 +0000
Subject: Bug #61469 [Opn->Nab]: simplexml_load_file() url encodes file names if they use a stream wrapper
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168758@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61469&edit=1

 ID:                 61469
 Updated by:         cataphract@php.net
 Reported by:        saschagros at gmail dot com
 Summary:            simplexml_load_file() url encodes file names if they
                     use a stream wrapper
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Linux/Windows
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

.


Previous Comments:
------------------------------------------------------------------------
[2012-03-23 12:33:19] cataphract@php.net

The fact file_get_contents "works just fine" is irrelevant. There's a difference
between what 1) URIs you're willing to accept and 2) which URIs you generate. Only the latter
must be well-formed. And in fact libxml generates correct URIs. The bug is in your custom stream
wrapper that doesn't parse the path in URI correctly and just takes it as is.

------------------------------------------------------------------------
[2012-03-22 14:00:44] saschagros at gmail dot com

temporary is not a remote URI that points to a HTTP resource. This is a local file.

If the space needs to be encoded internally, fine. But it has to be possible to access a file with a
space in it using a stream wrapper? After all, file_get_contents() works just fine.

------------------------------------------------------------------------
[2012-03-22 07:35:40] cataphract@php.net

Looks right. URIs cannot contain spaces. See RFC 3986.

------------------------------------------------------------------------
[2012-03-21 22:43:03] saschagros at gmail dot com

Description:
------------
Drupal uses custom stream wrappers for accessing files.

Given the file name "$imported_file = 'temporary://translated file.xlf'", the
following does not work:

$xml = simplexml_load_file($imported_file);

It results in the following warning:
simplexml_load_file(): I/O warning : failed to load external entity
"temporary://translated%20file.xlf"

However, this works just fine:

$xml_string = file_get_contents($imported_file);
$xml = simplexml_load_string($xml_string);



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61469&edit=1


Thread (7 messages)

« previous php.bugs (#168758) next »