~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-14 08:05:32 UTC
  • mto: (2992.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2994.
  • Revision ID: v.ladeuil+lp@free.fr-20071114080532-1zcuhjjlyz5ml2pu
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1514
1514
 
1515
1515
        :return: A new transport or None if the connection cannot be shared.
1516
1516
        """
1517
 
        (scheme, user, password, host, port, path) = self._split_url(other_base)
 
1517
        try:
 
1518
            (scheme, user, password,
 
1519
             host, port, path) = self._split_url(other_base)
 
1520
        except errors.InvalidURL:
 
1521
            # No hope in trying to reuse an existing transport for an invalid
 
1522
            # URL
 
1523
            return None
 
1524
 
1518
1525
        transport = None
1519
1526
        # Don't compare passwords, they may be absent from other_base or from
1520
1527
        # self and they don't carry more information than user anyway.