forked from seba/servefile
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:
parent
0334e74996
commit
65fcac5c49
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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":
|
||||||
|
|
Loading…
Reference in New Issue