mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(rpc): perform regex match against callback name
Since we're in the hot path, a constant re.compiled JSONP_EXPR is defined for checks against the callback. Additionally, reorganized `content_type` and `content` to avoid performing a DB query when we encounter a regex mismatch. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
12b4269ba8
commit
2cc44e8f28
2 changed files with 24 additions and 11 deletions
|
@ -624,3 +624,9 @@ def test_rpc_jsonp_callback():
|
|||
"/rpc?v=5&type=search&arg=big&callback=jsonCallback")
|
||||
assert response.headers.get("content-type") == "text/javascript"
|
||||
assert re.search(r'^/\*\*/jsonCallback\(.*\)$', response.text) is not None
|
||||
|
||||
# Test an invalid callback name; we get an application/json error.
|
||||
response = make_request(
|
||||
"/rpc?v=5&type=search&arg=big&callback=jsonCallback!")
|
||||
assert response.headers.get("content-type") == "application/json"
|
||||
assert response.json().get("error") == "Invalid callback name."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue