mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Patched HTML::Document#initialize call to Node.parse so that it includes the strict argument. [#330]
This commit is contained in:
parent
071fe79279
commit
670e22e372
2 changed files with 26 additions and 1 deletions
|
@ -17,7 +17,7 @@ module HTML #:nodoc:
|
|||
@root = Node.new(nil)
|
||||
node_stack = [ @root ]
|
||||
while token = tokenizer.next
|
||||
node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token)
|
||||
node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token, strict)
|
||||
|
||||
node_stack.last.children << node unless node.tag? && node.closing == :close
|
||||
if node.tag?
|
||||
|
|
|
@ -120,4 +120,29 @@ HTML
|
|||
assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => "")
|
||||
assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => nil)
|
||||
end
|
||||
|
||||
def test_parse_invalid_document
|
||||
assert_nothing_raised do
|
||||
doc = HTML::Document.new("<html>
|
||||
<table>
|
||||
<tr>
|
||||
<td style=\"color: #FFFFFF; height: 17px; onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" style=\"cursor:pointer; height: 17px;\"; nowrap onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" onmouseout=\"this.bgColor='#0066cc'; this.style.color='#FFFFFF'\" onmouseover=\"this.bgColor='#ffffff'; this.style.color='#0033cc'\">About Us</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>")
|
||||
end
|
||||
end
|
||||
|
||||
def test_invalid_document_raises_exception_when_strict
|
||||
assert_raises RuntimeError do
|
||||
doc = HTML::Document.new("<html>
|
||||
<table>
|
||||
<tr>
|
||||
<td style=\"color: #FFFFFF; height: 17px; onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" style=\"cursor:pointer; height: 17px;\"; nowrap onclick=\"window.location.href='http://www.rmeinc.com/about_rme.aspx'\" onmouseout=\"this.bgColor='#0066cc'; this.style.color='#FFFFFF'\" onmouseover=\"this.bgColor='#ffffff'; this.style.color='#0033cc'\">About Us</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>", true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue