From fadd1fa3d314639067404403651de52a7d2b72f7 Mon Sep 17 00:00:00 2001 From: mathieuravaux Date: Sun, 27 Feb 2011 01:52:08 +0100 Subject: Fixes ticket #6379. Improved the handling of Accept headers containing */*. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lookup_context#formats=` being too restrictive, "Accept: text/javascript, */*" resulted in [:js, "*/*"] formats instead of [:js, :html]. Signed-off-by: José Valim --- actionpack/lib/action_view/lookup_context.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 06975ffa2f..02114f46da 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -169,10 +169,13 @@ module ActionView # Overload formats= to reject ["*/*"] values. def formats=(values) - if values && values.size == 1 - value = values.first - values = nil if value == "*/*" - values << :html if value == :js + if values + values.pop if values.last == "*/*" + if values.size == 0 + values = nil + elsif values == [:js] + values << :html + end end super(values) end -- cgit v1.2.3