diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2007-03-28 16:42:21 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2007-03-28 16:42:21 +0000 |
commit | df3ee41126af8e34f4bf76e791a8817ede1ba87b (patch) | |
tree | 92970fab90ed13dc97b7f2c5109267ed3751ecbe /actionpack/lib | |
parent | 0228975a4ecfaf81e8d8b8662abdc91ff67dbf42 (diff) | |
download | rails-df3ee41126af8e34f4bf76e791a8817ede1ba87b.tar.gz rails-df3ee41126af8e34f4bf76e791a8817ede1ba87b.tar.bz2 rails-df3ee41126af8e34f4bf76e791a8817ede1ba87b.zip |
Improved the handling of broken accept headers
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6484 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/mime_type.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index b179fe2f89..44a60487b2 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -63,10 +63,12 @@ module Mime def parse(accept_header) # keep track of creation order to keep the subsequent sort stable - index = 0 - list = accept_header.split(/,/).map! do |i| - AcceptItem.new(index += 1, *i.split(/;\s*q=/)) - end.sort! + list = [] + accept_header.split(/,/).each_with_index do |header, index| + params = header.split(/;\s*q=/) + list << AcceptItem.new(index, *params) unless params.empty? + end + list.sort! # Take care of the broken text/xml entry by renaming or deleting it text_xml = list.index("text/xml") |