Rev 5514: (gz) Disallow urls like 'file:///C:' rather than raising IndexError (Jared in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Oct 22 19:10:26 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5514 [merge]
revision-id: pqm at pqm.ubuntu.com-20101022181024-0xj4kn2fc8s1cr3r
parent: pqm at pqm.ubuntu.com-20101022173435-z6cspzmcc689ybdz
parent: jared.bunting at peachjean.com-20101021222743-tn9n0cgzg3z8cb25
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-10-22 19:10:24 +0100
message:
  (gz) Disallow urls like 'file:///C:' rather than raising IndexError (Jared
   Bunting)
modified:
  bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
  bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py	2010-06-15 03:08:31 +0000
+++ b/bzrlib/tests/test_urlutils.py	2010-10-21 22:27:43 +0000
@@ -419,6 +419,8 @@
             from_url('file:///d:/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s'))
         self.assertEqual('/', from_url('file:///'))
 
+        self.assertRaises(InvalidURL, from_url, 'file:///C:')
+        self.assertRaises(InvalidURL, from_url, 'file:///c')
         self.assertRaises(InvalidURL, from_url, '/path/to/foo')
         # Not a valid _win32 url, no drive letter
         self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo')

=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py	2010-06-15 04:32:49 +0000
+++ b/bzrlib/urlutils.py	2010-10-21 22:27:43 +0000
@@ -224,8 +224,9 @@
         return '/'
 
     # usual local path with drive letter
-    if (win32_url[3] not in ('abcdefghijklmnopqrstuvwxyz'
-                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
+    if (len(win32_url) < 6
+        or win32_url[3] not in ('abcdefghijklmnopqrstuvwxyz'
+                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
         or win32_url[4] not in  '|:'
         or win32_url[5] != '/'):
         raise errors.InvalidURL(url, 'Win32 file urls start with'




More information about the bazaar-commits mailing list