Escape language codes before matching them in case they contain

characters with special meaning in a regexp. Closes #2318.
This commit is contained in:
Tom Hughes 2009-09-26 22:39:09 +00:00
parent 088bd1dcb2
commit f0d3831f12

View file

@ -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