Permalink
Browse files

Fix Mime::Type#=~ not using Regexp.quote

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent 75a133f commit 606cd61b9a2a710a27c2e482b5dace100cce9779 @fcheung fcheung committed with lifo Dec 21, 2008
Showing with 2 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_controller/mime_type.rb
  2. +1 −0 actionpack/test/controller/mime_type_test.rb
@@ -178,7 +178,7 @@ def ==(mime_type)
def =~(mime_type)
return false if mime_type.blank?
- regexp = Regexp.new(mime_type.to_s)
+ regexp = Regexp.new(Regexp.quote(mime_type.to_s))
(@synonyms + [ self ]).any? do |synonym|
synonym.to_s =~ regexp
end
@@ -88,5 +88,6 @@ def test_regexp_matcher
assert Mime::JS !~ "text/html"
assert !(Mime::JS !~ "text/javascript")
assert !(Mime::JS !~ "application/javascript")
+ assert Mime::HTML =~ 'application/xhtml+xml'
end
end

0 comments on commit 606cd61

Please sign in to comment.