Permalink
Browse files

current code ignores http header "Accept" if it

has ....,*/* .

It is possible to a device to send
request such that */* appear at the beginning of the
"Accept" header. This patch ensures that "Accept" header
is ignored for such cases too.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent c937ddb commit 61950a4b05ce1b5640ac3f3720f9a3368ce95a29 Neeraj Singh committed with josevalim Nov 22, 2010
@@ -48,7 +48,7 @@ def formats
@env["action_dispatch.request.formats"] ||=
if parameters[:format]
Array(Mime[parameters[:format]])
- elsif xhr? || (accept && accept !~ /,\s*\*\/\*/)
+ elsif xhr? || (accept && accept !~ /,\s*\*\/\*|\*\/\*,/)
accepts
else
[Mime::HTML]
@@ -216,6 +216,12 @@ def test_js_or_html
assert_response 406
end
+ def test_json_or_yaml_with_leading_star_star
+ @request.accept = "*/*, application/json"
+ get :json_xml_or_html
+ assert_equal 'HTML', @response.body
+ end
+
def test_json_or_yaml
xhr :get, :json_or_yaml
assert_equal 'JSON', @response.body

0 comments on commit 61950a4

Please sign in to comment.