php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9727 Unable to use @ in URL passwords with fopen()
Submitted: 2001-03-13 18:21 UTC Modified: 2001-04-03 09:44 UTC
From: aaron dot webb at corenetworks dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: rh 6.1
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: aaron dot webb at corenetworks dot com
New email:
PHP Version: OS:

 

 [2001-03-13 18:21 UTC] aaron dot webb at corenetworks dot com
I'm running 4.0.4pl1 on redhat 6.1.  I've tried (raw and regular) urlencoding my ftp password to use with fopen, but if there's a @ in it it says 'bad file descriptor'.  

I can open any file via ftp just fine, as long as there's no @ in the filename.  The 'allow url fopen' (can't remember the exact name) is set to ON in my php.ini.  

Here's my script:


<html>
<body>
<? 

$pword = 'stuff@stuff';
$server = "servername";
$filename = "filename";

$pword = urlencode($pword); 

echo $filename = 'ftp://username:' . $pword . "@$servername/$filename";

$fd = fopen ($filename, "r");

echo $contents = fread ($fd, 100);

fclose ($fd);
?>
</body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-13 22:54 UTC] sniper@php.net
There is one bug in your script:
.
.
$server = "servername";
.
.

echo $filename = 'ftp://username:'.$pword."@$servername/$filename";
.
.

You haven't got $servername set but $server.
Try changing that. Reopen if this wasn't the problem.

--Jani

 [2001-03-14 14:32 UTC] aaron dot webb at corenetworks dot com
Here's my exact code with only the username and password changed (oops - i sent a slightly altered version before, to change the server names/passwords).  This version has the following behaviour:

If I use a password containing only letters/numbers, I can open and read the file no problem.
If I use the same password, and specify a file that does not exist, I get a message saying 'file not found' and one saying 'file or directory does not exist'.

If I use a password containing the @ symbol, I get a message that says 'invalid file descriptor', no matter if the file exists or not.

Code:

$pword = 'password';
$server = "prefix";

$pword = urlencode($pword); 

echo $filename = 'ftp://username:' . $pword . "@$server.domain.com/path/file.txt";

$fd = fopen ($filename, "r");

echo $contents = fread ($fd, 100);


fclose ($fd);

 [2001-04-03 09:44 UTC] sniper@php.net
Works for me just fine. (with a passwd containing a @ )

Please try the latest CVS snapshot from http://snaps.php.net/ 

Reopen this bug report if problem still persists.

--Jani



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 08:01:28 2024 UTC