]> git.openstreetmap.org Git - rails.git/commitdiff
Escape language codes before matching them in case they contain
authorTom Hughes <tom@compton.nu>
Sat, 26 Sep 2009 22:39:09 +0000 (22:39 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 26 Sep 2009 22:39:09 +0000 (22:39 +0000)
characters with special meaning in a regexp. Closes #2318.

vendor/plugins/http_accept_language/lib/http_accept_language.rb

index 1bedd6c742ff28e9793576688bd8a05aefe15185..1266a3e645560b26bec1f3a7faba4f5479dddf21 100644 (file)
@@ -49,7 +49,7 @@ module HttpAcceptLanguage
   def compatible_language_from(array)
     user_preferred_languages.map do |x|
       array.find do |y|
   def compatible_language_from(array)
     user_preferred_languages.map do |x|
       array.find do |y|
-        y.to_s =~ /^#{x.to_s}(-|$)/
+        y.to_s =~ /^#{Regexp.escape(x.to_s)}(-|$)/
       end
     end.compact.first
   end
       end
     end.compact.first
   end