commit fa007b2e422a604f6f3a855720009c2406fb1a96 Author: Isis Lovecruft isis@torproject.org Date: Sat Feb 14 03:08:58 2015 +0000
Bridge._constructBridgeLine() won't be handed an invalid addresses.
The only way that Bridge._constructBridgeLine() is called is through Bridge.getBridgeLine() when vanilla bridges are requested. Because of all the sanitisation in Stem and the rest of BridgeDB's parsers, no type of bridgerequest, no matter how malformed, will ever result in an invalid addrport from Bridge._getVanillaForRequest().
Secondly, we'll never get anything other than IPv4 and IPv6 addresses, for the same reasons.
* REMOVE lines which raise MalformedBridgeInfo in Bridge._constructBridgeLine(). --- lib/bridgedb/bridges.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/lib/bridgedb/bridges.py b/lib/bridgedb/bridges.py index 901baf5..3c47967 100644 --- a/lib/bridgedb/bridges.py +++ b/lib/bridgedb/bridges.py @@ -860,8 +860,6 @@ class Bridge(BridgeBackwardsCompatibility): line. :param bool bridgePrefix: if ``True``, prefix the :term:`Bridge Line` with ``'Bridge '``. - :raises MalformedBridgeInfo: if the **addrport** didn't turn out to be - a 2-tuple containing ``(ipaddress, port)``. :rtype: string :returns: A bridge line suitable for adding into a ``torrc`` file or Tor Launcher. @@ -869,11 +867,7 @@ class Bridge(BridgeBackwardsCompatibility): if not addrport: return
- try: - address, port, version = addrport - except (TypeError, ValueError): - raise MalformedBridgeInfo("Can't process addrport: %r" % addrport) - + address, port, version = addrport bridgeLine = []
if bridgePrefix: @@ -883,8 +877,6 @@ class Bridge(BridgeBackwardsCompatibility): bridgeLine.append("%s:%d" % (str(address), port)) elif version == 6: bridgeLine.append("[%s]:%d" % (str(address), port)) - else: - raise MalformedBridgeInfo("IP version must be 4 or 6")
if includeFingerprint: bridgeLine.append("%s" % self.fingerprint)
tor-commits@lists.torproject.org