Skip to content

Commit

Permalink
This fixes #64 but only for Python 3; Python 2 fails the test. I'm cl…
Browse files Browse the repository at this point in the history
…ueless about what the right thing to do is.
  • Loading branch information
mcdonc authored and Flimm committed Jun 1, 2017
1 parent c130bc2 commit d9d9260
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion waitress/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ def close(self):
def split_uri(uri):
# urlsplit handles byte input by returning bytes on py3, so
# scheme, netloc, path, query, and fragment are bytes
scheme, netloc, path, query, fragment = urlparse.urlsplit(uri)
try:
scheme, netloc, path, query, fragment = urlparse.urlsplit(uri)
except UnicodeError:
raise ParsingError('Bad URI')
return (
tostr(scheme),
tostr(netloc),
Expand Down
5 changes: 5 additions & 0 deletions waitress/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ def test_split_url_https(self):
self.assertEqual(self.proxy_scheme, 'https')
self.assertEqual(self.proxy_netloc, 'localhost:8080')

def test_split_uri_unicode_error_raises_parsing_error(self):
# See https://github.com/Pylons/waitress/issues/64
from waitress.parser import ParsingError
self.assertRaises(ParsingError, self._callFUT, b'/\xd0')

class Test_get_header_lines(unittest.TestCase):

def _callFUT(self, data):
Expand Down

0 comments on commit d9d9260

Please sign in to comment.