Permalink
Browse files

regular expressions are usually ASCII-encoded, so force_encoding the …

…content of a Node to the encoding of the regular expression is wrong.
  • Loading branch information...
1 parent a210aff commit d6953cbfd3b6e06eceba715c60e288b6d7db0d49 @wycats wycats committed Jun 7, 2010
@@ -23,6 +23,7 @@ class Tokenizer #:nodoc:
# Create a new Tokenizer for the given text.
def initialize(text)
+ text.encode! if text.encoding_aware?
@scanner = StringScanner.new(text)
@position = 0
@line = 0
@@ -267,14 +267,12 @@ def assert_select(*args, &block)
if match_with = equals[:text]
matches.delete_if do |match|
text = ""
- text.force_encoding(match_with.encoding) if text.respond_to?(:force_encoding)
stack = match.children.reverse
while node = stack.pop
if node.tag?
stack.concat node.children.reverse
else
content = node.content
- content.force_encoding(match_with.encoding) if content.respond_to?(:force_encoding)
text << content
end
end

0 comments on commit d6953cb

Please sign in to comment.