[Patches] [ python-Patches-817379 ] urllib2 does not allow for absolute ftp paths

SourceForge.net noreply at sourceforge.net
Sun Feb 15 15:57:40 EST 2004


Patches item #817379, was opened at 2003-10-03 21:45
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=817379&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Mihai Ibanescu (misa)
Assigned to: Jeremy Hylton (jhylton)
Summary: urllib2 does not allow for absolute ftp paths

Initial Comment:
urllib does the unquote() on FTP paths too early;
therefore, URLs like:

ftp://myname@host.dom/%2Fetc/motd

are unquoted as:

//etc/motd

and then the wrong thing happens.

The correct behaviour is documented in:

http://ietf.org/rfc/rfc1738.txt section 3.2.2 


<quote>
   Within a name or CWD component, the characters "/"
and ";" are
   reserved and must be encoded. The components are
decoded prior to
   their use in the FTP protocol.  In particular, if
the appropriate FTP
   sequence to access a particular file requires
supplying a string
   containing a "/" as an argument to a CWD or RETR
command, it is
   necessary to encode each "/".

   For example, the URL
<URL:ftp://myname@host.dom/%2Fetc/motd> is
   interpreted by FTP-ing to "host.dom", logging in as
"myname"
   (prompting for a password if it is asked for), and
then executing
   "CWD /etc" and then "RETR motd". This has a
different meaning from
   <URL:ftp://myname@host.dom/etc/motd> which would
"CWD etc" and then
   "RETR motd"; the initial "CWD" might be executed
relative to the
   default directory for "myname". On the other hand,
   <URL:ftp://myname@host.dom//etc/motd>, would "CWD "
with a null
   argument, then "CWD etc", and then "RETR motd".
</quote>


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

>Comment By: Martin v. Löwis (loewis)
Date: 2004-02-15 21:57

Message:
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as urllib2.py 1.61 and
1.53.6.3, NEWS 1.831.4.90.

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

Comment By: John J Lee (jjlee)
Date: 2003-11-30 23:26

Message:
Logged In: YES 
user_id=261020

This still hasn't been applied.  The patch looks correct to me. 

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

Comment By: Jeremy Hylton (jhylton)
Date: 2003-10-03 22:59

Message:
Logged In: YES 
user_id=31392

Sounds like an easy fix.  I'll do it tonight.


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

Comment By: Mihai Ibanescu (misa)
Date: 2003-10-03 21:48

Message:
Logged In: YES 
user_id=205865

Note: patch was generated a long time ago against python
2.2.2, and I was sure I uploaded it to sourceforge. Anyway,
patch still applies cleanly to 2.3.1 urllib2; the bug is
still present in HEAD.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=817379&group_id=5470



More information about the Patches mailing list