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.
This commit is contained in:
Sebastian Lohff 2021-06-08 23:23:51 +02:00
parent 0334e74996
commit 65fcac5c49
2 changed files with 4 additions and 1 deletions

View File

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

View File

@ -542,7 +542,9 @@ class DirListingHandler(FileBaseHandler):
self.send_header("Content-Length", str(len(listing))) self.send_header("Content-Length", str(len(listing)))
self.send_header('Connection', 'close') self.send_header('Connection', 'close')
self.end_headers() 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): def convertSize(self, size):
for ext in "KMGT": for ext in "KMGT":