Commit 8a410e7b authored by Kunpei Sakai's avatar Kunpei Sakai Committed by Nigel Tao

html: fix wrong comparison in foster parenting algorithm

Fixes golang/go#23071

Change-Id: I383e13bfd87e32ffb775dff54c46b66b090e5017
Reviewed-on: https://go-review.googlesource.com/131475
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
parent 4bcd98cc
...@@ -255,7 +255,7 @@ func (p *parser) fosterParent(n *Node) { ...@@ -255,7 +255,7 @@ func (p *parser) fosterParent(n *Node) {
} }
} }
if template != nil && (table == nil || j < i) { if template != nil && (table == nil || j > i) {
template.AppendChild(n) template.AppendChild(n)
return return
} }
......
...@@ -329,6 +329,7 @@ var renderTestBlacklist = map[string]bool{ ...@@ -329,6 +329,7 @@ var renderTestBlacklist = map[string]bool{
`<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true, `<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true,
`<a><table><a></table><p><a><div><a>`: true, `<a><table><a></table><p><a><div><a>`: true,
`<a><table><td><a><table></table><a></tr><a></table><a>`: true, `<a><table><td><a><table></table><a></tr><a></table><a>`: true,
`<template><a><table><a>`: true,
// A similar reparenting situation involving <nobr>: // A similar reparenting situation involving <nobr>:
`<!DOCTYPE html><body><b><nobr>1<table><nobr></b><i><nobr>2<nobr></i>3`: true, `<!DOCTYPE html><body><b><nobr>1<table><nobr></b><i><nobr>2<nobr></i>3`: true,
// A <plaintext> element is reparented, putting it before a table. // A <plaintext> element is reparented, putting it before a table.
......
...@@ -1130,6 +1130,20 @@ ...@@ -1130,6 +1130,20 @@
| <select> | <select>
| <body> | <body>
#data
<template><template><table>Foo
#errors
#document
| <html>
| <head>
| <template>
| content
| <template>
| content
| "Foo"
| <table>
| <body>
#data #data
<template><template><frame> <template><template><frame>
#errors #errors
...@@ -1297,3 +1311,16 @@ ...@@ -1297,3 +1311,16 @@
| content | content
| "Foo" | "Foo"
| <body> | <body>
#data
<template><a><table><a>
#errors
#document
| <html>
| <head>
| <template>
| content
| <a>
| <a>
| <table>
| <body>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment