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

Exception when i call a wrong URL #281

Closed
a-marcel opened this issue Jun 27, 2014 · 3 comments
Closed

Exception when i call a wrong URL #281

a-marcel opened this issue Jun 27, 2014 · 3 comments

Comments

@a-marcel
Copy link

Hello,

if i call the URL "/xxx.xxx?test=123&ord=%n" there is an Key Error Exception:

From callback <function uwsgi_pypy_wsgi_handler at 0x0000000002edcbd8>:
Traceback (most recent call last):
  File "c callback", line 472, in uwsgi_pypy_wsgi_handler
  File "./falcon/api.py", line 88, in __call__
    req = self._request_type(env)
  File "./falcon/request.py", line 193, in __init__
    self.query_string = uri.decode(env['QUERY_STRING'])
  File "./falcon/util/uri.py", line 187, in decode
    char, byte = _HEX_TO_BYTE[token[:2]]
KeyError: 'n'

File: falcon/util/uri.py Line: 187

       for token in tokens[1:]:
            char, byte = _HEX_TO_BYTE[token[:2]]
            decoded_uri += char + token[2:]

            if only_ascii:
                only_ascii = (byte <= 127)

I'll fixed that with:

        for token in tokens[1:]:
            try:
                char, byte = _HEX_TO_BYTE[token[:2]]
            except KeyError:
                continue
            decoded_uri += char + token[2:]

            if only_ascii:
                only_ascii = (byte <= 127)
@lwcolton
Copy link
Contributor

This is a bug. The query string that you supplied has an invalid escape character (%n) The query string decode function should raise an HttpBadRequest error if the query string is invalid. I will submit a pull request with a fix shortly.

@philiptzou
Copy link
Contributor

Perhaps related to #588 and I have already submit a pull request to fix it: #597

@kgriffs
Copy link
Member

kgriffs commented May 3, 2016

I just did a quick check and this seams to be fixed in 1.0.0rc2. Please reopen if you find this is not the case. Thanks!

@kgriffs kgriffs closed this as completed May 3, 2016
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

4 participants