Fixed the HTML scanner used by assert_tag where a infinite loop could be...

Fixed the HTML scanner used by assert_tag where a infinite loop could be caused by a stray less-than sign in the input #1270 [Jamis Buck]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1297 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 979880dd
*SVN*
* Fixed the HTML scanner used by assert_tag where a infinite loop could be caused by a stray less-than sign in the input #1270 [Jamis Buck]
* Added functionality to assert_tag, so you can now do tests on the siblings of a node, to assert that some element comes before or after the element in question, or just to assert that some element exists as a sibling #1226 [Jamis Buck]
* Added better error handling for regexp caching expiration
......
......@@ -277,7 +277,10 @@ def to_s
"</#{@name}>"
else
s = "<#{@name}"
@attributes.each { |k,v| s << " #{k}='#{v.to_s.gsub(/'/,"\\\\'")}'" }
@attributes.each do |k,v|
s << " #{k}"
s << "='#{v.gsub(/'/,"\\\\'")}'" if String === v
end
s << " /" if @closing == :self
s << ">"
@children.each { |child| s << child.to_s }
......
......@@ -63,7 +63,7 @@ def scan_tag
# Scan all text up to the next < character and return it.
def scan_text
@scanner.scan(/[^<]*/)
@scanner.getch + (@scanner.scan(/[^<]*/) || "")
end
# Counts the number of newlines in the text and updates the current line
......@@ -78,9 +78,17 @@ def update_current_line(text)
def consume_quoted_regions
text = ""
loop do
match = @scanner.scan_until(/['">]/) or break
match = @scanner.scan_until(/['"<>]/) or break
delim = @scanner.matched
if delim == "<"
match = match.chop
@scanner.pos -= 1
end
text << match
break if (delim = @scanner.matched) == ">"
break if delim == "<" || delim == ">"
# consume the conqued region
while match = @scanner.scan_until(/[\\#{delim}]/)
text << match
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册