未验证 提交 4b0cd81f 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #38295 from bibstha/add_test_verify_token

Use path instead of fullpath on validating authenticity token
......@@ -381,7 +381,7 @@ def valid_per_form_csrf_token?(token, session) # :doc:
if per_form_csrf_tokens
correct_token = per_form_csrf_token(
session,
request.fullpath.chomp("/"),
request.path.chomp("/"),
request.request_method
)
......
......@@ -835,6 +835,18 @@ def test_accepts_token_for_correct_path_and_method
assert_response :success
end
def test_accepts_token_with_path_with_query_params
get :index
form_token = assert_presence_and_fetch_form_csrf_token
assert_matches_session_token_on_server form_token
@request.env["PATH_INFO"] = "/per_form_tokens/post_one"
@request.env["QUERY_STRING"] = "key=value"
assert_nothing_raised do
post :post_one, params: { custom_authenticity_token: form_token }
end
end
def test_rejects_garbage_path
get :index
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册