Index: Lib/ftplib.py =================================================================== --- Lib/ftplib.py (revisione 84233) +++ Lib/ftplib.py (copia locale) @@ -571,7 +571,11 @@ def mkd(self, dirname): '''Make a directory, return its full pathname.''' - resp = self.sendcmd('MKD ' + dirname) + resp = self.voidcmd('MKD ' + dirname) + # fix around non-compliant implementations such as IIS shipped + # with Windows server 2003 + if not resp.startswith('257'): + return '' return parse257(resp) def rmd(self, dirname): @@ -580,7 +584,11 @@ def pwd(self): '''Return current working directory.''' - resp = self.sendcmd('PWD') + resp = self.voidcmd('PWD') + # fix around non-compliant implementations such as IIS shipped + # with Windows server 2003 + if not resp.startswith('257'): + return '' return parse257(resp) def quit(self): Index: Lib/test/test_ftplib.py =================================================================== --- Lib/test/test_ftplib.py (revisione 84233) +++ Lib/test/test_ftplib.py (copia locale) @@ -606,7 +606,19 @@ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit') self.assertFalse(is_client_connected()) + def test_parse257(self): + self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar') + self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar') + self.assertEqual(ftplib.parse257('257 ""'), '') + self.assertEqual(ftplib.parse257('257 "" created'), '') + self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"') + # The 257 response is supposed to include the directory + # name and in case it contains embedded double-quotes + # they must be doubled (see RFC-959, chapter 7, appendix 2). + self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar') + self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar') + class TestIPv6Environment(TestCase): def setUp(self):