diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 28eef311fd9c2cafd079785c67b5ff46af442ba9..c68355254841006ff544de3a3ba733e704694ef0 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Update html-scanner to handle CDATA sections better. Closes #2970. [Jamis Buck] + * Don't put flash in session if sessions are disabled. [Jeremy Kemper] * Strip out trailing &_= for raw post bodies. Closes #2868. [Sam Stephenson] 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 4f02e2d4212a21ae3b125acbfe24d29e30ffd969..fb961570c426c696c3d0ec65aa03a397edece760 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb @@ -150,6 +150,11 @@ def parse(parent, line, pos, content, strict=true) end end + if scanner.skip(/!\[CDATA\[/) + scanner.scan_until(/\]\]>/) + return CDATA.new(parent, line, pos, scanner.pre_match) + end + closing = ( scanner.scan(/\//) ? :close : nil ) return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:]+/) name.downcase! @@ -256,6 +261,14 @@ def ==(node) content == node.content end end + + # A CDATA node is simply a text node with a specialized way of displaying + # itself. + class CDATA < Text + def to_s + "" + end + end # A Tag is any node that represents markup. It may be an opening tag, a # closing tag, or a self-closing tag. It has a name, and may have a hash of diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb index ce9d3b280085b927743de5703e5d6b415b0f9de3..b950e846284bb41047263a584f82feed009c842a 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb @@ -52,6 +52,9 @@ def scan_tag if @scanner.scan(/!--/) # comment tag << @scanner.matched tag << (@scanner.scan_until(/--\s*>/) || @scanner.scan_until(/\Z/)) + elsif @scanner.scan(/!\[CDATA\[/) + tag << @scanner.matched + tag << @scanner.scan_until(/\]\]>/) elsif @scanner.scan(/!/) # doctype tag << @scanner.matched tag << consume_quoted_regions