提交 d6953cbf 编写于 作者: W wycats

regular expressions are usually ASCII-encoded, so force_encoding the content...

regular expressions are usually ASCII-encoded, so force_encoding the content of a Node to the encoding of the regular expression is wrong.
上级 a210aff2
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册