aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/vendor/html-scanner
diff options
context:
space:
mode:
authorJeffrey Hardy <packagethief@gmail.com>2008-10-22 16:03:21 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2008-10-23 19:16:12 -0700
commit1a1822726189f3cfff305dea62e5cfbdbc0da577 (patch)
tree493e7103122ccca2883aab36abb053cd6b625172 /actionpack/lib/action_controller/vendor/html-scanner
parent838cb1aa507746b3562931bb63cf4f474363e17a (diff)
downloadrails-1a1822726189f3cfff305dea62e5cfbdbc0da577.tar.gz
rails-1a1822726189f3cfff305dea62e5cfbdbc0da577.tar.bz2
rails-1a1822726189f3cfff305dea62e5cfbdbc0da577.zip
Fix that HTML::Node.parse would blow up on unclosed CDATA sections.
If an unclosed CDATA section is encountered and parsing is strict, an exception will be raised. Otherwise, we consider the remainder of the line to be the section contents. This is consistent with HTML::Tokenizer#scan_tag. Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/lib/action_controller/vendor/html-scanner')
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/node.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
index 472c5b2bae..47ddc6146f 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
@@ -150,7 +150,14 @@ module HTML #:nodoc:
end
if scanner.skip(/!\[CDATA\[/)
- scanner.scan_until(/\]\]>/)
+ unless scanner.skip_until(/\]\]>/)
+ if strict
+ raise "expected ]]> (got #{scanner.rest.inspect} for #{content})"
+ else
+ scanner.skip_until(/\Z/)
+ end
+ end
+
return CDATA.new(parent, line, pos, scanner.pre_match.gsub(/<!\[CDATA\[/, ''))
end