mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-21 12:13:38 +09:00
Backport #39337 by @nschloe Follow-up to https://github.com/go-gitea/gitea/pull/38034. bluemonday only keeps an element without attributes if it was registered via `AllowNoAttrs`. The MathML rules only used `AllowAttrs(...).OnElements(...)`, so plain `<mi>x</mi>`, `<mrow>`, `<msqrt>` and friends were stripped to bare text. Since real-world MathML is almost entirely attribute-less elements, nearly every formula collapsed. The existing test missed it because its only case gave every element an attribute. Also fills the remaining gaps against MathML Core (https://www.w3.org/TR/mathml-core/): `rowspan` on `mtd` alongside `columnspan`, the `maction` element with `actiontype` and `selection`, and the reserved global attributes `intent` and `arg`. Tests cover attribute-less round-trips, table cell spans, and `maction` with `intent`/`arg`. Co-authored-by: Nico Schlömer <nschloe@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
Nico Schlömer
wxiaoguang
parent
2c7a442692
commit
0b5c721971
@@ -62,7 +62,10 @@ func TestSanitizer(t *testing.T) {
|
||||
`<picture><source media="a"><source media="b"><img alt="c" src="d"></picture>`, `<picture><source media="a"><source media="b"><img alt="c" src="d"></picture>`,
|
||||
|
||||
// MathML
|
||||
`<math display="display" class="foo"><mi mathcolor="c" class="bar"></mi></math>`, `<math display="display"><mi mathcolor="c"></mi></math>`,
|
||||
`<math display="block" class="foo"><mi mathcolor="c" class="bar"></mi></math>`, `<math display="block"><mi mathcolor="c"></mi></math>`,
|
||||
`<math><mfrac><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><msqrt><mn>2</mn></msqrt></mfrac></math>`, `<math><mfrac><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><msqrt><mn>2</mn></msqrt></mfrac></math>`,
|
||||
`<math><mtable><mtr><mtd rowspan="2" columnspan="2"><mn>1</mn></mtd></mtr></mtable></math>`, `<math><mtable><mtr><mtd rowspan="2" columnspan="2"><mn>1</mn></mtd></mtr></mtable></math>`,
|
||||
`<math><maction actiontype="toggle" selection="2"><mi intent="power($b,$e)" arg="b">x</mi><mn>2</mn></maction></math>`, `<math><maction actiontype="toggle" selection="2"><mi intent="power($b,$e)" arg="b">x</mi><mn>2</mn></maction></math>`,
|
||||
|
||||
// Disallow dangerous url schemes
|
||||
`<a href="javascript:alert('xss')">bad</a>`, `bad`,
|
||||
|
||||
Reference in New Issue
Block a user