regular expressions are usually ASCII-encoded, so force_encoding the content of a Node to the encoding of the regular expression is wrong.

This commit is contained in:
wycats 2010-06-07 17:00:09 -04:00
parent a210aff210
commit d6953cbfd3
2 changed files with 1 additions and 2 deletions

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