#47202 [Opn->WFx]: FTP fopen wrapper and # in file names
ID: 47202
Updated by: hradtke@php.net
Reported By: smlerman at gmail dot com
-Status: Open
+Status: Wont fix
Bug Type: Streams related
Operating System: *
PHP Version: 5.2.8
New Comment:
The php_url_parse_ex function intentionally strips the # character from
the filename. I did some research and see that this was done to fix Bug
#31705 (http://bugs.php.net/bug.php?id=31705).
From http://www.w3.org/Addressing/URL/4_URI_Recommentations.html
:
The hash ("#", ASCII 23 hex) character is reserved as a delimiter to
separate the URI of an object from a fragment identifier.
This behavior is intentional.
Previous Comments:
------------------------------------------------------------------------
[2009-01-23 15:22:38] smlerman at gmail dot com
Description:
------------
It seems that the FTP fopen wrapper truncates file names when it
encounters a pound sign (#). The FTP server's log shows a request for
"file".
I have tried replacing the # with %23 (the result of urlencode), but
the server sees that as a request for "file%231.txt".
Reproduce code:
---------------
// Use fopen wrapper
$data =
file_get_contents("ftp://username:password@ftp.example.com/file
#1.txt");
var_dump(strlen($data));
// Use ftp_* functions
$conn = ftp_connect('ftp.example.com');
ftp_login($conn, 'username', 'password');
ftp_get($conn, 'C:\\test.txt', 'file#1.txt', FTP_BINARY);
var_dump(filesize('C:\\test.txt'));
Expected result:
----------------
int(7)
int(7)
Actual result:
--------------
Warning: file_get_contents(ftp://...@ftp.example.com/file#1.txt) [<a
href='function.file-get-contents'>function.file-get-contents</a>]:
failed to open stream: FTP server reports 550 /file : The system cannot
find the path specified. in...
int(0)
int(7)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47202&edit=1
Thread (3 messages)