Browse Source

Fix encoding handling for file listing with py2

File listings with -l that contained files with umlauts or other special
chars could break the directory listing. Hopefully one of the last
python2 fixes before I drop support for this.
fix-weird-encoding-problem-in-tests
Sebastian Lohff 11 months ago
parent
commit
65fcac5c49
  1. 1
      ChangeLog
  2. 4
      servefile/servefile.py

1
ChangeLog

@ -13,6 +13,7 @@ Unreleased @@ -13,6 +13,7 @@ Unreleased
SERVEFILE_SECONDARY_PORT
* fixed broken redirect when filename contained umlauts or other characters
that should have been quoted
* fixed broken special char handling in directory listing for python2
* drop python3.5 support

4
servefile/servefile.py

@ -542,7 +542,9 @@ class DirListingHandler(FileBaseHandler): @@ -542,7 +542,9 @@ class DirListingHandler(FileBaseHandler):
self.send_header("Content-Length", str(len(listing)))
self.send_header('Connection', 'close')
self.end_headers()
self.wfile.write(listing.encode())
if sys.version_info.major >= 3:
listing = listing.encode()
self.wfile.write(listing)
def convertSize(self, size):
for ext in "KMGT":

Loading…
Cancel
Save