New submission from Josh Lee: While SimpleHTTPServer from Python2 would happily spit out whatever bytes were in the directory listing, Python3's http.server logs an error and closes the connection without responding to the HTTP request.
$ mkdir $'\xff' $ ls \377/ $ python3 -m http.server Serving HTTP on 0.0.0.0 port 8000 ... ---------------------------------------- Exception happened during processing of request from ('74.125.59.145', 19648) Traceback (most recent call last): File "/home/josh/local/lib/python3.5/socketserver.py", line 321, in _handle_request_noblock self.process_request(request, client_address) File "/home/josh/local/lib/python3.5/socketserver.py", line 347, in process_request self.finish_request(request, client_address) File "/home/josh/local/lib/python3.5/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/home/josh/local/lib/python3.5/socketserver.py", line 681, in __init__ self.handle() File "/home/josh/local/lib/python3.5/http/server.py", line 398, in handle self.handle_one_request() File "/home/josh/local/lib/python3.5/http/server.py", line 386, in handle_one_request method() File "/home/josh/local/lib/python3.5/http/server.py", line 677, in do_GET f = self.send_head() File "/home/josh/local/lib/python3.5/http/server.py", line 716, in send_head return self.list_directory(path) File "/home/josh/local/lib/python3.5/http/server.py", line 772, in list_directory % (urllib.parse.quote(linkname), html.escape(displayname))) File "/home/josh/local/lib/python3.5/urllib/parse.py", line 688, in quote string = string.encode(encoding, errors) UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed ---------------------------------------- ---------- components: Library (Lib) messages: 225016 nosy: durin42, jleedev priority: normal severity: normal status: open title: Empty response from http.server when directory listing contains invalid unicode versions: Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22165> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com