(Fixes issue 365) Fixed browser plugin regex when using Ruby 1.9.2 and UTF-8 strings (like Microsoft® DRM)

git-svn-id: https://beef.googlecode.com/svn/trunk@1059 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
antisnatchor
2011-07-11 13:33:43 +00:00
parent 7bd377005f
commit 2ee589af14

View File

@@ -53,8 +53,12 @@ module Filters
# verify the browser_plugins string is valid
def self.is_valid_browser_plugins?(str)
return false if not is_non_empty_string?(str)
return false if str.length > 400
return (str =~ /[^\w\d\s()-.,;_!\302\256]/).nil? # \302\256 is the (r) character
return false if str.length > 400
if RUBY_VERSION >= "1.9" && str.encoding === Encoding.find('UTF-8')
return (str =~ /[^\w\d\s()-.,;_!\302\256]/u).nil?
else
return (str =~ /[^\w\d\s()-.,;_!\302\256]/n).nil?
end
end
end