File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
import base58
2
2
import base64
3
3
import binascii
4
+ import os
4
5
5
6
import idna
6
7
from netaddr import IPAddress
@@ -160,7 +161,7 @@ def address_string_to_bytes(proto, addr_string):
160
161
raise ValueError ("invalid P2P multihash: %s" % mm )
161
162
return b'' .join ([size , mm ])
162
163
elif proto .code == P_UNIX :
163
- addr_string_bytes = addr_string . encode ( "ascii" )
164
+ addr_string_bytes = os . fsencode ( addr_string )
164
165
size = code_to_varint (len (addr_string_bytes ))
165
166
return b'' .join ([size , binascii .hexlify (addr_string_bytes )])
166
167
elif proto .code in (P_DNS , P_DNS4 , P_DNS6 ):
@@ -200,7 +201,7 @@ def address_bytes_to_string(proto, buf):
200
201
elif proto .code == P_UNIX :
201
202
buf = binascii .unhexlify (buf )
202
203
size , num_bytes_read = read_varint_code (buf )
203
- return buf [num_bytes_read :]. decode ( 'ascii' )
204
+ return os . fsdecode ( buf [num_bytes_read :])
204
205
elif proto .code in (P_DNS , P_DNS4 , P_DNS6 ):
205
206
buf = binascii .unhexlify (buf )
206
207
size , num_bytes_read = read_varint_code (buf )
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ def test_invalid(addr_str):
80
80
"/ip4/127.0.0.1/udp/1234" ,
81
81
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234" ,
82
82
"/unix/a/b/c/d/e" ,
83
+ "/unix/Überrschung!/大柱" ,
83
84
"/unix/stdio" ,
84
85
"/ip4/1.2.3.4/tcp/80/unix/a/b/c/d/e/f" ,
85
86
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234/unix/stdio" ,
You can’t perform that action at this time.
0 commit comments