From: Tom Hughes Date: Sat, 26 Sep 2009 22:39:09 +0000 (+0000) Subject: Escape language codes before matching them in case they contain X-Git-Tag: live~6633 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f0d3831f12a6588adc7aaa9f428150c9d8d3ff3f Escape language codes before matching them in case they contain characters with special meaning in a regexp. Closes #2318. --- diff --git a/vendor/plugins/http_accept_language/lib/http_accept_language.rb b/vendor/plugins/http_accept_language/lib/http_accept_language.rb index 1bedd6c74..1266a3e64 100644 --- a/vendor/plugins/http_accept_language/lib/http_accept_language.rb +++ b/vendor/plugins/http_accept_language/lib/http_accept_language.rb @@ -49,7 +49,7 @@ module HttpAcceptLanguage 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