File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ def decode(self, encoded_packet):
7979 self .data = None
8080 ep = ep [1 :]
8181 dash = ep .find ('-' )
82- if dash > 10 :
83- raise ValueError ('too many attachments' )
8482 attachment_count = 0
8583 if dash > 0 and ep [0 :dash ].isdigit ():
84+ if dash > 10 :
85+ raise ValueError ('too many attachments' )
8686 attachment_count = int (ep [0 :dash ])
8787 ep = ep [dash + 1 :]
8888 if ep and ep [0 :1 ] == '/' :
Original file line number Diff line number Diff line change @@ -261,7 +261,12 @@ def test_decode_too_many_binary_packets(self):
261261
262262 def test_decode_attachment_count_too_long (self ):
263263 with pytest .raises (ValueError ):
264- packet .Packet (encoded_packet = '6' + ('1' * 11 ) + '-{"a":"123}' )
264+ packet .Packet (encoded_packet = '6' + ('1' * 11 ) + '-{"a":"123"}' )
265+
266+ def test_decode_dash_in_payload (self ):
267+ pkt = packet .Packet (encoded_packet = '6{"a":"0123456789-"}' )
268+ assert pkt .data ["a" ] == "0123456789-"
269+ assert pkt .attachment_count == 0
265270
266271 def test_data_is_binary_list (self ):
267272 pkt = packet .Packet ()
You can’t perform that action at this time.
0 commit comments