Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Handle errors during create_url_adapter#2994

Merged
davidism merged 3 commits intopallets:masterfrom
jarek:werkzeug-640-exceptions-during-bind
Nov 13, 2018
Merged

Handle errors during create_url_adapter#2994
davidism merged 3 commits intopallets:masterfrom
jarek:werkzeug-640-exceptions-during-bind

Conversation

@jarek
Copy link
Contributor

@jarekjarek commentedNov 12, 2018
edited
Loading

If create_url_adapter raises (which it can if werkzeug cannot bind environment, for example onnon-ASCII non-printable Host header), we should handle it as other routing exceptions rather than raising through. This allows us to return a HTTP 400, rather than a 500 from unhandled exception.

This came up inpallets/werkzeug#640

Do we need to add it to any documentation or changelogs?

If create_url_adapter raises (which it can if werkzeug cannot bindenvironment, for example on non-ASCII Host header), we handle it asother routing exceptions rather than raising through.refpallets/werkzeug#640
@jarek
Copy link
ContributorAuthor

Will take a look at the tests, It Worked On My Machine™

@jarek
Copy link
ContributorAuthor

Failures are in the test doingresponse = app.test_client().get('/', headers={'host': 'ąśź.com'})

On my local machine:

  • on Python 3.5.2, testing withget('/', headers={'host': 'ąöж'}) fails (HTTP 200 is returned?!)
  • on Python 2.7.12, testing withget('/', headers={'host': 'ąöж'}) works (HTTP 400 is returned)
  • on Python 3.5.2, testing withget('/', headers={'host': '\x8a'}) (the test case given in original issue) works as expected (HTTP 400 is returned)
  • on Python 2.7.12, testing withget('/', headers={'host': '\x8a'}) raises exception in the test code (I think?):
venv2/local/lib/python2.7/site-packages/werkzeug/test.py:830: in get    return self.open(*args, **kw)flask/testing.py:200: in open    follow_redirects=follow_redirectsvenv2/local/lib/python2.7/site-packages/werkzeug/test.py:803: in open    response = self.run_wsgi_app(environ, buffered=buffered)venv2/local/lib/python2.7/site-packages/werkzeug/test.py:718: in run_wsgi_app    self.cookie_jar.extract_wsgi(environ, rv[2])venv2/local/lib/python2.7/site-packages/werkzeug/test.py:191: in extract_wsgi    U2Request(get_current_url(environ)),venv2/local/lib/python2.7/site-packages/werkzeug/wsgi.py:99: in get_current_url    return uri_to_iri(''.join(tmp))venv2/local/lib/python2.7/site-packages/werkzeug/urls.py:614: in uri_to_iri    uri = url_parse(to_unicode(uri, charset))venv2/local/lib/python2.7/site-packages/werkzeug/_compat.py:206: in to_unicode    return x.decode(charset, errors)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _input = 'http://\x8a/', errors = 'strict'    def decode(input, errors='strict'):>       return codecs.utf_8_decode(input, errors, True)E       UnicodeDecodeError: 'utf8' codec can't decode byte 0x8a in position 7: invalid start byte

http://\x8a/ looks like it's trying to do more with that Host header than I expected. Will dig in some more.

We've discovered that passing Unicode in Host actually works, except fortest client limitations on Python 2 - and the only things that don'twork are non-printable characters.
@davidismdavidism added this to the1.1 milestoneNov 13, 2018
@davidismdavidism merged commitca23b7b intopallets:masterNov 13, 2018
@jarekjarek deleted the werkzeug-640-exceptions-during-bind branchNovember 13, 2018 18:56
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsNov 14, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

1.1.0

Development

Successfully merging this pull request may close these issues.

2 participants

@jarek@davidism

[8]ページ先頭

©2009-2026 Movatter.jp