Skip to content

Commit a3c94be

Browse files
committed
Do not allow empty text MultiAddrs, they must always start with a forward slash
1 parent c0d9fa4 commit a3c94be

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

multiaddr/multiaddr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def decapsulate(self, other):
188188
For example:
189189
/ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
190190
"""
191-
s1 = str(self)
192-
s2 = str(other)
191+
s1 = self.to_bytes()
192+
s2 = other.to_bytes()
193193
try:
194194
idx = s1.rindex(s2)
195195
except ValueError:

multiaddr/transforms.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515

1616
def string_to_bytes(string):
17-
if not string:
18-
return b''
19-
2017
bs = []
2118
for proto, codec, value in string_iter(string):
2219
bs.append(varint.encode(proto.code))

0 commit comments

Comments
 (0)