Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyramid 1.3 falls when %FF in query string #639

Closed
appetito opened this issue Jul 20, 2012 · 1 comment
Closed

pyramid 1.3 falls when %FF in query string #639

appetito opened this issue Jul 20, 2012 · 1 comment

Comments

@appetito
Copy link

When 'PATH_INFO': '/\xff', we get this

Traceback (most recent call last):
File "/home/staff/ve/lib/python2.7/site-packages/pyramid_exclog-0.6-py2.7.egg/pyramid_exclog/init.py", line 44, in exclog_tween
return handler(request)
File "/home/staff/ve/lib/python2.7/site-packages/pyramid_tm-0.3-py2.7.egg/pyramid_tm/init.py", line 61, in tm_tween
response = handler(request)
File "/home/staff/ve/lib/python2.7/site-packages/pyramid-1.3-py2.7.egg/pyramid/router.py", line 79, in handle_request
info = routes_mapper(request)
File "/home/staff/ve/lib/python2.7/site-packages/pyramid-1.3-py2.7.egg/pyramid/urldispatch.py", line 79, in call
raise URLDecodeError(e.encoding, e.object, e.start, e.end, e.reason)
URLDecodeError: 'utf8' codec can't decode byte 0xff in position 16: invalid start byte

@mcdonc
Copy link
Member

mcdonc commented Jul 20, 2012

Right. Not a bug. \xff alone is not a valid utf-8 codepoint. Pyramid assumes the URI is encoded in UTF-8. It'd be the same as trying to do:

>>> '\xff'.decode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

Either send URLs to Pyramid that are valid UTF-8, or use WebOb's Request.decode(thecharset) method in a request factory to turn it in to UTF-8.

@mcdonc mcdonc closed this as completed Jul 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants