Skip to content

Commit

Permalink
Correctly handle single media with q value. Fixes #736.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottwb committed Feb 7, 2012
1 parent 339c99b commit 3b203f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion actionpack/lib/action_dispatch/http/mime_type.rb
Expand Up @@ -82,6 +82,7 @@ def ==(item)
class << self

TRAILING_STAR_REGEXP = /(text|application)\/\*/
Q_SEPARATOR_REGEXP = /;\s*q=/

def lookup(string)
LOOKUP[string]
Expand All @@ -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
Expand All @@ -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!

Expand Down

0 comments on commit 3b203f7

Please sign in to comment.