Skip to content

Instantly share code, notes, and snippets.

@xntrik
Created June 22, 2015 04:47
Show Gist options
  • Save xntrik/460d856afb4269bbb5f1 to your computer and use it in GitHub Desktop.
Save xntrik/460d856afb4269bbb5f1 to your computer and use it in GitHub Desktop.
~/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