Skip to content

Commit

Permalink
Merge pull request #74 from cherrypy/bugfix/options-path-processing
Browse files Browse the repository at this point in the history
WIP: Bypass URI as path only if absolute for OPTIONS
  • Loading branch information
jaraco committed Oct 14, 2019
2 parents bdbd6ee + dc9592b commit 02f7a17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ v8.2.0

- Deprecated use of negative timeouts as alias for
infinite timeouts in ``ThreadPool.stop``.
- :cp-issue:`1662` via :pr:`74`: For OPTION requests,
bypass URI as path if it does not appear absolute.

v8.1.0
======
Expand Down
6 changes: 3 additions & 3 deletions cheroot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,14 @@ def read_request_line(self):
self.simple_response('400 Bad Request', 'Malformed Request-URI')
return False

uri_is_absolute_form = (scheme or authority)

if self.method == b'OPTIONS':
# TODO: cover this branch with tests
path = (
uri
# https://tools.ietf.org/html/rfc7230#section-5.3.4
if self.proxy_mode or uri == ASTERISK
if (self.proxy_mode and uri_is_absolute_form)
else path
)
elif self.method == b'CONNECT':
Expand Down Expand Up @@ -871,8 +873,6 @@ def read_request_line(self):
authority = path = _authority
scheme = qs = fragment = EMPTY
else:
uri_is_absolute_form = (scheme or authority)

disallowed_absolute = (
self.strict_mode
and not self.proxy_mode
Expand Down

0 comments on commit 02f7a17

Please sign in to comment.