From a1f340fa1a26fd29f1369cbc91755e7519813dd0 Mon Sep 17 00:00:00 2001 From: Andrew Balholm Date: Fri, 27 Jul 2012 16:05:25 +1000 Subject: [PATCH] exp/html: parse CDATA sections in foreign content Also convert NUL to U+FFFD in comments. Pass 23 additional tests. R=nigeltao CC=golang-dev https://golang.org/cl/6446055 --- src/pkg/exp/html/parse.go | 4 ++ .../html/testlogs/plain-text-unsafe.dat.log | 6 +- src/pkg/exp/html/testlogs/tests21.dat.log | 40 +++++------ src/pkg/exp/html/token.go | 72 ++++++++++++++++--- 4 files changed, 91 insertions(+), 31 deletions(-) diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index 82edb2263f..986e9bbe46 100644 --- a/src/pkg/exp/html/parse.go +++ b/src/pkg/exp/html/parse.go @@ -390,6 +390,10 @@ func (p *parser) reconstructActiveFormattingElements() { // read reads the next token from the tokenizer. func (p *parser) read() error { + // CDATA sections are allowed only in foreign content. + n := p.oe.top() + p.tokenizer.cdataOK = n != nil && n.Namespace != "" + p.tokenizer.Next() p.tok = p.tokenizer.Token() if p.tok.Type == ErrorToken { diff --git a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log index 65ee908f55..b63a237a15 100644 --- a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log +++ b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log @@ -8,9 +8,9 @@ PASS "