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 472c5b2..c4f8341 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb @@ -150,8 +150,16 @@ module HTML #:nodoc: end if scanner.skip(/!\[CDATA\[/) - scanner.scan_until(/\]\]>/) - return CDATA.new(parent, line, pos, scanner.pre_match.gsub(//) + cdata_content = scanner.pre_match.sub(/ (got #{scanner.rest.inspect} for " + "" end end diff --git a/actionpack/test/controller/html-scanner/node_test.rb b/actionpack/test/controller/html-scanner/node_test.rb index 240f01a..ff8e985 100644 --- a/actionpack/test/controller/html-scanner/node_test.rb +++ b/actionpack/test/controller/html-scanner/node_test.rb @@ -56,7 +56,7 @@ class NodeTest < Test::Unit::TestCase node = HTML::Node.parse(nil,0,0,s) assert node.attributes.has_key?("foo") assert node.attributes.has_key?("bar") - assert "", node.to_s + assert_equal "", node.to_s end def test_parse_with_unclosed_tag @@ -65,4 +65,36 @@ class NodeTest < Test::Unit::TestCase assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) } assert node.attributes.has_key?("onmouseover") end + + def test_parse_cdata + s = "" + node = nil + assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) } + assert node.is_a?(HTML::CDATA) + assert_equal "foo bar", node.content + assert_equal "", node.to_s + end + + def test_parse_unclosed_cdata + s = "" + node = nil + assert_nothing_raised { node = HTML::Node.parse(nil,0,0,s,false) } + assert node.is_a?(HTML::CDATA) + assert_equal "