From: Nigel Tao Date: Tue, 10 Jan 2012 23:15:40 +0000 (+1100) Subject: html: propagate foreign namespaces only when adding foreign content. X-Git-Tag: weekly.2012-01-15~88 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aa033c20b356b608e2fcc51e284cf711f952309b;p=gostls13.git html: propagate foreign namespaces only when adding foreign content. Pass tests10.dat, test 31:

a | | | |

| | | |

| "a" Also pass test 32:
    a R=andybalholm CC=golang-dev https://golang.org/cl/5527064 --- diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go index 7077612e7a..43c04727ab 100644 --- a/src/pkg/html/parse.go +++ b/src/pkg/html/parse.go @@ -243,10 +243,9 @@ func (p *parser) addText(text string) { // addElement calls addChild with an element node. func (p *parser) addElement(tag string, attr []Attribute) { p.addChild(&Node{ - Type: ElementNode, - Data: tag, - Namespace: p.top().Namespace, - Attr: attr, + Type: ElementNode, + Data: tag, + Attr: attr, }) } @@ -1736,7 +1735,9 @@ func parseForeignContent(p *parser) bool { panic("html: bad parser state: unexpected namespace") } adjustForeignAttributes(p.tok.Attr) + namespace := p.top().Namespace p.addElement(p.tok.Data, p.tok.Attr) + p.top().Namespace = namespace case EndTagToken: for i := len(p.oe) - 1; i >= 0; i-- { if p.oe[i].Namespace == "" { diff --git a/src/pkg/html/parse_test.go b/src/pkg/html/parse_test.go index 91c8388b3a..c929c25772 100644 --- a/src/pkg/html/parse_test.go +++ b/src/pkg/html/parse_test.go @@ -184,7 +184,7 @@ func TestParser(t *testing.T) { {"tests4.dat", -1}, {"tests5.dat", -1}, {"tests6.dat", -1}, - {"tests10.dat", 31}, + {"tests10.dat", 33}, } for _, tf := range testFiles { f, err := os.Open("testdata/webkit/" + tf.filename)