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>
|