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

 ID:                 47202
 Updated by:         langemei...@php.net
 Reported by:        smlerman at gmail dot com
 Summary:            FTP fopen wrapper and # in file names
-Status:             Wont fix
+Status:             Re-Opened
 Type:               Bug
 Package:            Streams related
 Operating System:   *
 PHP Version:        5.2.8
 Block user comment: N
 Private report:     N

 New Comment:

I was able to fix the problem for the ssh2 wrapper. I assume it can be fixed 
for 
ftp too. See bug #59794


Previous Comments:
------------------------------------------------------------------------
[2009-03-03 07:05:27] hrad...@php.net

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.



------------------------------------------------------------------------
[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:passw...@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 https://bugs.php.net/bug.php?id=47202&edit=1

Reply via email to