From c8d9e0521ea3851c6f267e9d525b57975ce5246a Mon Sep 17 00:00:00 2001 From: tyraniter Date: Mon, 23 Mar 2020 11:46:24 +0800 Subject: [PATCH] fix non-ascii filename downloading error.when download files with non-ascii filename,the 'length' part in the packet is the length of string but not bytes,so throw an index-out-of-bounts error --- lib/common/packets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/packets.py b/lib/common/packets.py index f65772b48..517f32579 100644 --- a/lib/common/packets.py +++ b/lib/common/packets.py @@ -165,7 +165,7 @@ def build_task_packet(taskName, data, resultID): totalPacket = struct.pack('=H', 1) packetNum = struct.pack('=H', 1) resultID = struct.pack('=H', resultID) - length = struct.pack('=L', len(data)) + length = struct.pack('=L', len(data.encode("UTF-8"))) return taskType + totalPacket + packetNum + resultID + length + data.encode("UTF-8") def parse_result_packet(packet, offset=0):