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.
Sebastian Lohff 4 months ago
parent
commit
65fcac5c49
2 changed files with 4 additions and 1 deletions
  1. 1
    0
      ChangeLog
  2. 3
    1
      servefile/servefile.py

+ 1
- 0
ChangeLog View File

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

+ 3
- 1
servefile/servefile.py View File

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

Loading…
Cancel
Save