mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-23 05:03:39 +09:00
enhance: allow attribute-less MathML elements and complete the Core allowlist (#39337)
Follow-up to https://github.com/go-gitea/gitea/pull/38034. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
wxiaoguang
parent
be7cde7539
commit
4892a55e29
@@ -70,6 +70,7 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
|
||||
"mi", "mn", "mo", "mtext", "mspace", "ms",
|
||||
// layout elements
|
||||
"mrow", "mfrac", "msqrt", "mroot", "mstyle", "merror", "mpadded", "mphantom",
|
||||
"maction", // although MDN says "maction" is deprecated, we still need to allow it, otherwise, if it is removed, the layout will be wrong
|
||||
// scripting elements
|
||||
"msub", "msup", "msubsup", "munder", "mover", "munderover", "mmultiscripts", "mprescripts", "none",
|
||||
// tabular elements
|
||||
@@ -77,10 +78,11 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
|
||||
// semantic annotations
|
||||
"semantics", "annotation", "annotation-xml",
|
||||
}
|
||||
policy.AllowNoAttrs().OnElements(mathMLElements...) // most MathML elements carry no attributes
|
||||
policy.AllowAttrs("display", "alttext").OnElements("math")
|
||||
policy.AllowAttrs(
|
||||
// global presentation attributes
|
||||
"dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "mathvariant", "scriptlevel",
|
||||
// global attributes
|
||||
"dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "mathvariant", "scriptlevel", "intent", "arg",
|
||||
// operator attributes
|
||||
"accent", "accentunder", "fence", "form", "largeop", "lspace", "maxsize", "minsize", "movablelimits", "rspace", "separator", "stretchy", "symmetric",
|
||||
// space and padding attributes
|
||||
@@ -90,7 +92,9 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
|
||||
// table attributes
|
||||
"columnalign", "columnlines", "columnspacing", "frame", "framespacing", "rowalign", "rowlines", "rowspacing",
|
||||
// cell attributes
|
||||
"columnspan",
|
||||
"columnspan", "rowspan",
|
||||
// maction attributes
|
||||
"actiontype", "selection",
|
||||
// annotation attribute
|
||||
"encoding",
|
||||
).OnElements(mathMLElements...)
|
||||
|
||||
Reference in New Issue
Block a user