Skip to content
Browse files

Correctly handle single media with q value. Fixes #736.

  • Loading branch information...
1 parent 339c99b commit 3b203f7cb6c54963f74d1ab4237bf7403cc3bf8f @scottwb scottwb committed Feb 6, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 actionpack/lib/action_dispatch/http/mime_type.rb
View
4 actionpack/lib/action_dispatch/http/mime_type.rb
@@ -82,6 +82,7 @@ def ==(item)
class << self
TRAILING_STAR_REGEXP = /(text|application)\/\*/
+ Q_SEPARATOR_REGEXP = /;\s*q=/
def lookup(string)
LOOKUP[string]
@@ -108,6 +109,7 @@ def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], s
def parse(accept_header)
if accept_header !~ /,/
+ accept_header = accept_header.split(Q_SEPARATOR_REGEXP).first
if accept_header =~ TRAILING_STAR_REGEXP
parse_data_with_trailing_star($1)
else
@@ -117,7 +119,7 @@ def parse(accept_header)
# keep track of creation order to keep the subsequent sort stable
list, index = [], 0
accept_header.split(/,/).each do |header|
- params, q = header.split(/;\s*q=/)
+ params, q = header.split(Q_SEPARATOR_REGEXP)
if params.present?
params.strip!

0 comments on commit 3b203f7

Please sign in to comment.
Something went wrong with that request. Please try again.