Skip to content

Commit 45f5645

Browse files
committed
Explicitly match .json and .xml extension when used as last element of
the path component of a URI. This permits items like JWT that have multiple '.' separated components to be passed in the path of the URI.
1 parent e22edfd commit 45f5645

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Fixed:
3131
encoded/compressed. (John Rouillard)
3232
- In REST interface do not raise UsageError for invalid api version.
3333
Return json error with proper message. Fixes crash. (John Rouillard)
34+
- In REST interface, only allow .json or .xml (if supported) as
35+
extensions. All other paths with a . in then will be passed through
36+
without change. This allows items like a JWT to be passed as a path
37+
element. (John Rouillard)
3438

3539
Features:
3640

roundup/rest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,15 @@ def dispatch(self, method, uri, input):
19611961
# default (application/json)
19621962
ext_type = os.path.splitext(urlparse(uri).path)[1][1:]
19631963

1964+
# Use explicit list of extensions. Even if xml isn't supported
1965+
# recognize it as a valid directive.
1966+
if ext_type in ['json', 'xml']:
1967+
# strip extension so uri make sense
1968+
# .../issue.json -> .../issue
1969+
uri = uri[:-(len(ext_type) + 1)]
1970+
else:
1971+
ext_type = None
1972+
19641973
# headers.get('Accept') is never empty if called here.
19651974
# accept_type will be set to json if there is no Accept header
19661975
# accept_type wil be empty only if there is an Accept header

0 commit comments

Comments
 (0)