Skip to content

Commit b932ba0

Browse files
committed
KSES: add MathML tags.
These tags are needed for the new Math block, which is included in WP 6.9. See WordPress/gutenberg#72182. See #10307. Fixes #64115. git-svn-id: https://develop.svn.wordpress.org/trunk@61017 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d354b6c commit b932ba0

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

src/wp-includes/kses.php

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,185 @@
415415
'wbr' => array(),
416416
);
417417

418+
// https://www.w3.org/TR/mathml-core/#global-attributes
419+
// Except common attributes added by _wp_add_global_attributes.
420+
$math_global_attributes = array(
421+
'displaystyle' => true,
422+
'scriptlevel' => true,
423+
'mathbackground' => true,
424+
'mathcolor' => true,
425+
'mathsize' => true,
426+
// Common attributes also defined by _wp_add_global_attributes.
427+
// We do not want to add all those global attributes though.
428+
'class' => true,
429+
'data-*' => true,
430+
'dir' => true,
431+
'id' => true,
432+
'style' => true,
433+
);
434+
435+
$math_overunder_attributes = array(
436+
'accentunder' => true,
437+
'accent' => true,
438+
);
439+
440+
$allowedposttags = array_merge(
441+
$allowedposttags,
442+
array(
443+
// https://www.w3.org/TR/mathml-core/#the-top-level-math-element
444+
'math' => array_merge(
445+
$math_global_attributes,
446+
array(
447+
'display' => true,
448+
)
449+
),
450+
451+
// https://www.w3.org/TR/mathml-core/#token-elements
452+
// https://www.w3.org/TR/mathml-core/#text-mtext
453+
'mtext' => $math_global_attributes,
454+
// https://www.w3.org/TR/mathml-core/#the-mi-element
455+
'mi' => array_merge(
456+
$math_global_attributes,
457+
array(
458+
'mathvariant' => true,
459+
)
460+
),
461+
// https://www.w3.org/TR/mathml-core/#number-mn
462+
'mn' => $math_global_attributes,
463+
// https://www.w3.org/TR/mathml-core/#operator-fence-separator-or-accent-mo
464+
'mo' => array_merge(
465+
$math_global_attributes,
466+
array(
467+
'form' => true,
468+
'fence' => true,
469+
'separator' => true,
470+
'lspace' => true,
471+
'rspace' => true,
472+
'stretchy' => true,
473+
'symmetric' => true,
474+
'maxsize' => true,
475+
'minsize' => true,
476+
'largeop' => true,
477+
'movablelimits' => true,
478+
)
479+
),
480+
// https://www.w3.org/TR/mathml-core/#space-mspace
481+
'mspace' => array_merge(
482+
$math_global_attributes,
483+
array(
484+
'width' => true,
485+
'height' => true,
486+
'depth' => true,
487+
)
488+
),
489+
// https://www.w3.org/TR/mathml-core/#string-literal-ms
490+
'ms' => $math_global_attributes,
491+
492+
// https://www.w3.org/TR/mathml-core/#general-layout-schemata
493+
// https://www.w3.org/TR/mathml-core/#horizontally-group-sub-expressions-mrow
494+
'mrow' => $math_global_attributes,
495+
// https://www.w3.org/TR/mathml-core/#fractions-mfrac
496+
'mfrac' => array_merge(
497+
$math_global_attributes,
498+
array(
499+
'linethickness' => true,
500+
)
501+
),
502+
// https://www.w3.org/TR/mathml-core/#radicals-msqrt-mroot
503+
'msqrt' => $math_global_attributes,
504+
'mroot' => $math_global_attributes,
505+
// https://www.w3.org/TR/mathml-core/#style-change-mstyle
506+
'mstyle' => $math_global_attributes,
507+
// https://www.w3.org/TR/mathml-core/#error-message-merror
508+
'merror' => $math_global_attributes,
509+
// https://www.w3.org/TR/mathml-core/#adjust-space-around-content-mpadded
510+
'mpadded' => array_merge(
511+
$math_global_attributes,
512+
array(
513+
'width' => true,
514+
'height' => true,
515+
'depth' => true,
516+
'lspace' => true,
517+
'voffset' => true,
518+
)
519+
),
520+
// https://www.w3.org/TR/mathml-core/#making-sub-expressions-invisible-mphantom
521+
'mphantom' => $math_global_attributes,
522+
523+
// https://www.w3.org/TR/mathml-core/#script-and-limit-schemata
524+
// https://www.w3.org/TR/mathml-core/#subscripts-and-superscripts-msub-msup-msubsup
525+
'msub' => $math_global_attributes,
526+
'msup' => $math_global_attributes,
527+
'msubsup' => $math_global_attributes,
528+
// https://www.w3.org/TR/mathml-core/#underscripts-and-overscripts-munder-mover-munderover
529+
'munder' => array_merge( $math_global_attributes, $math_overunder_attributes ),
530+
'mover' => array_merge( $math_global_attributes, $math_overunder_attributes ),
531+
'munderover' => array_merge( $math_global_attributes, $math_overunder_attributes ),
532+
// https://www.w3.org/TR/mathml-core/#prescripts-and-tensor-indices-mmultiscripts
533+
'mmultiscripts' => $math_global_attributes,
534+
'mprescripts' => $math_global_attributes,
535+
536+
// https://www.w3.org/TR/mathml-core/#tabular-math
537+
// https://www.w3.org/TR/mathml-core/#table-or-matrix-mtable
538+
'mtable' => array_merge(
539+
$math_global_attributes,
540+
array(
541+
// Non-standard, used by temml/katex.
542+
// https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mtable
543+
'columnalign' => true,
544+
'rowspacing' => true,
545+
'columnspacing' => true,
546+
'align' => true,
547+
'rowalign' => true,
548+
'columnlines' => true,
549+
'rowlines' => true,
550+
'frame' => true,
551+
'framespacing' => true,
552+
'width' => true,
553+
)
554+
),
555+
// https://www.w3.org/TR/mathml-core/#row-in-table-or-matrix-mtr
556+
'mtr' => array_merge(
557+
$math_global_attributes,
558+
array(
559+
// Non-standard, used by temml/katex.
560+
// https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mtr
561+
'columnalign' => true,
562+
'rowalign' => true,
563+
)
564+
),
565+
// https://www.w3.org/TR/mathml-core/#entry-in-table-or-matrix-mtd
566+
'mtd' => array_merge(
567+
$math_global_attributes,
568+
array(
569+
'columnspan' => true,
570+
'rowspan' => true,
571+
// Non-standard, used by temml/katex.
572+
// https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mtd
573+
'columnalign' => true,
574+
'rowalign' => true,
575+
)
576+
),
577+
578+
// https://www.w3.org/TR/mathml-core/#semantics-and-presentation
579+
'semantics' => $math_global_attributes,
580+
'annotation' => array_merge(
581+
$math_global_attributes,
582+
array(
583+
'encoding' => true,
584+
)
585+
),
586+
587+
// Non-standard but widely supported, used by temml/katex.
588+
'menclose' => array_merge(
589+
$math_global_attributes,
590+
array(
591+
'notation' => true,
592+
)
593+
),
594+
)
595+
);
596+
418597
/**
419598
* @var array[] $allowedtags Array of KSES allowed HTML elements.
420599
* @since 1.0.0

0 commit comments

Comments
 (0)