public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Patched HTML::Document#initialize call to Node.parse so that it includes the 
strict argument. [#330]
jimmyebaker (author)
Tue Jun 24 22:21:58 -0700 2008
jeremy (committer)
Tue Jun 24 23:11:35 -0700 2008
commit  670e22e3724791f51d639f409930fba5af920081
tree    c8151b176b010c563da9de37717a36277aea6b13
parent  071fe79279e89e650acce6613f13027527d01650
...
17
18
19
20
 
21
22
23
...
17
18
19
 
20
21
22
23
0
@@ -17,7 +17,7 @@ module HTML #:nodoc:
0
       @root = Node.new(nil)
0
       node_stack = [ @root ]
0
       while token = tokenizer.next
0
-        node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token)
0
+        node = Node.parse(node_stack.last, tokenizer.line, tokenizer.position, token, strict)
0
 
0
         node_stack.last.children << node unless node.tag? && node.closing == :close
0
         if node.tag?
...
120
121
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
0
@@ -120,4 +120,29 @@ HTML
0
     assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => "")
0
     assert doc.find(:tag => "div", :attributes => { :id => "map" }, :content => nil)
0
   end
0
+
0
+  def test_parse_invalid_document
0
+    assert_nothing_raised do
0
+      doc = HTML::Document.new("<html>
0
+        <table>
0
+          <tr>
0
+            <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>
0
+          </tr>
0
+        </table>
0
+      </html>")
0
+    end
0
+  end
0
+
0
+  def test_invalid_document_raises_exception_when_strict
0
+    assert_raises RuntimeError do
0
+      doc = HTML::Document.new("<html>
0
+        <table>
0
+          <tr>
0
+            <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>
0
+          </tr>
0
+        </table>
0
+      </html>", true)
0
+    end
0
+  end
0
+
0
 end

Comments