Rev 2994: Fix 161819: Detect invalid transport reuse attempts in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Nov 14 18:24:32 GMT 2007


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

------------------------------------------------------------
revno: 2994
revision-id: pqm at pqm.ubuntu.com-20071114182425-x73jp620qoazf94g
parent: pqm at pqm.ubuntu.com-20071114173258-zikev37621jxgj15
parent: v.ladeuil+lp at free.fr-20071114170353-66b0f3acc92olju5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-11-14 18:24:25 +0000
message:
  Fix 161819: Detect invalid transport reuse attempts
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
    ------------------------------------------------------------
    revno: 2992.1.1
    merged: v.ladeuil+lp at free.fr-20071114170353-66b0f3acc92olju5
    parent: pqm at pqm.ubuntu.com-20071114162431-vdx7u28fh4et71b6
    parent: v.ladeuil+lp at free.fr-20071114080532-1zcuhjjlyz5ml2pu
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Wed 2007-11-14 18:03:53 +0100
    message:
      Fix 161819: Detect invalid transport reuse attempts
    ------------------------------------------------------------
    revno: 2990.2.2
    merged: v.ladeuil+lp at free.fr-20071114080532-1zcuhjjlyz5ml2pu
    parent: v.ladeuil+lp at free.fr-20071114075654-fnlbodh0xzc68h24
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 161819
    timestamp: Wed 2007-11-14 09:05:32 +0100
    message:
      Detect invalid transport reuse attempts by catching invalid URLs.
      
      * bzrlib/transport/__init__.py:
      (ConnectedTransport._reuse_for): Catch invalid URLs and returns
      None.
      
      * bzrlib/tests/test_transport_implementations.py:
      (TransportTests.test__reuse_for): _reuse_for now returns None for
      invalid URLs.
    ------------------------------------------------------------
    revno: 2990.2.1
    merged: v.ladeuil+lp at free.fr-20071114075654-fnlbodh0xzc68h24
    parent: pqm at pqm.ubuntu.com-20071114070314-fdmaj14v4x59z1yv
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 161819
    timestamp: Wed 2007-11-14 08:56:54 +0100
    message:
      ConnectedTransport._reuse_for fails to deal with local URLs.
      
      * bzrlib/tests/test_transport_implementations.py:
      (TransportTests.test__reuse_for): Reproduce bug 161819.
=== modified file 'NEWS'
--- a/NEWS	2007-11-14 08:23:57 +0000
+++ b/NEWS	2007-11-14 17:03:53 +0000
@@ -45,6 +45,9 @@
    * A progress bar has been added for knitpack -> knitpack fetching.
      (Robert Collins, #157789)
 
+   * Detect invalid transport reuse attempts by catching invalid URLs.
+     (Vincent Ladeuil, #161819)
+
    * Do no use timeout in HttpServer anymore.
      (Vincent Ladeuil, #158972).
 
@@ -52,9 +55,6 @@
      retrying an http request or some programming errors may be masked.
      (Vincent Ladeuil, #160012)
 
-   * Don't use timeout in HttpServer anymore.
-     (Vincent Ladeuil, #158972).
-
    * Fix multiple connections during checkout --lightweight.
      (Vincent Ladeuil, #159150)
 

=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-11-04 15:29:17 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2007-11-14 08:05:32 +0000
@@ -1151,6 +1151,8 @@
         else:
             port = 1234
         self.assertIsNot(t, t._reuse_for(new_url(port=port)))
+        # No point in trying to reuse a transport for a local URL
+        self.assertIs(None, t._reuse_for('/valid_but_not_existing'))
 
     def test_connection_sharing(self):
         t = self.get_transport()

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-11-04 15:29:17 +0000
+++ b/bzrlib/transport/__init__.py	2007-11-14 08:05:32 +0000
@@ -1514,7 +1514,14 @@
 
         :return: A new transport or None if the connection cannot be shared.
         """
-        (scheme, user, password, host, port, path) = self._split_url(other_base)
+        try:
+            (scheme, user, password,
+             host, port, path) = self._split_url(other_base)
+        except errors.InvalidURL:
+            # No hope in trying to reuse an existing transport for an invalid
+            # URL
+            return None
+
         transport = None
         # Don't compare passwords, they may be absent from other_base or from
         # self and they don't carry more information than user anyway.




More information about the bazaar-commits mailing list