Created
June 22, 2015 04:47
-
-
Save xntrik/460d856afb4269bbb5f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/beef/beef2015jun ± git diff core/filters/base.rb | |
diff --git a/core/filters/base.rb b/core/filters/base.rb | |
index 33ee772..9bf65df 100644 | |
--- a/core/filters/base.rb | |
+++ b/core/filters/base.rb | |
@@ -22,7 +22,7 @@ module Filters | |
# @return [Boolean] Whether or not the only characters in str are specified in chars | |
def self.only?(chars, str) | |
regex = Regexp.new('[^' + chars + ']') | |
- regex.match(str).nil? | |
+ regex.match(str.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')).nil? | |
end | |
# Check if one or more characters in 'chars' are in 'str' | |
@@ -31,7 +31,7 @@ module Filters | |
# @return [Boolean] Whether one of the characters exists in the string | |
def self.exists?(chars, str) | |
regex = Regexp.new(chars) | |
- not regex.match(str).nil? | |
+ not regex.match(str.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')).nil? | |
end | |
# Check for null char |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment