Skip to content

Commit

Permalink
utf-8 filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Feb 17, 2024
1 parent 275e555 commit 73d12fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions partftpy/TftpPacketTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def encode(self):
filename = self.filename
mode = self.mode
if not isinstance(filename, bytes):
filename = filename.encode("ascii")
filename = filename.encode("utf-8", "replace")
if not isinstance(self.mode, bytes):
mode = mode.encode("ascii")

Expand Down Expand Up @@ -227,7 +227,7 @@ def decode(self):
mystruct = struct.unpack(fmt, shortbuf)

tftpassert(len(mystruct) == 2, "malformed packet")
self.filename = mystruct[0].decode("ascii")
self.filename = mystruct[0].decode("utf-8", "replace")
self.mode = mystruct[1].decode("ascii").lower() # force lc - bug 17
log.debug("set filename to %s", self.filename)
log.debug("set mode to %s", self.mode)
Expand Down

0 comments on commit 73d12fc

Please sign in to comment.