Skip SSML-containing data-semantic-* attributes in output wrapper#1432
Open
reteps wants to merge 1 commit intomathjax:developfrom
Open
Skip SSML-containing data-semantic-* attributes in output wrapper#1432reteps wants to merge 1 commit intomathjax:developfrom
reteps wants to merge 1 commit intomathjax:developfrom
Conversation
SRE enrichment adds data-semantic-speech, data-semantic-prefix, data-semantic-postfix, and data-semantic-summary attributes containing raw SSML markup to MathML nodes. When handleAttributes() copies these to SVG output elements and the SVG is serialized via outerHTML (HTML serialization), the unescaped < and > in SSML attribute values produce invalid XML. This breaks usage where SVG output is loaded as a data:image/svg+xml URI or written to .svg files. These attributes are already set directly on output DOM nodes by the speech system (WebWorker.setSpeechAttribute), so skipping them in handleAttributes() has no effect on the explorer or speech output. The plain-text equivalents (data-semantic-*-none) are unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SRE enrichment adds these attributes containing raw SSML markup (with literal
<,>,") to MathML nodes. WhenhandleAttributes()copies them to SVG output elements and the SVG is serialized, the unescaped<and>in attribute values produce invalid XML.My understanding is that
MathJax.startup.adaptor.outerHTMLis still a valid API we can use.This is a issue with webkit < 26.0 (https://developer.chrome.com/blog/escape-attributes, https://webkit.org/blog/17333/webkit-features-in-safari-26-0/).
Fix
Added attributes to
skipAttributesso they are no longer copied from the internal MathML tree to the output DOM.The speech system (
WebWorker.setSpeechAttribute) already sets these attributes directly on output DOM nodes during speech generation. The explorer reads them from that path.Disclosure
I root-caused this bug, and created this fix with Claude 4.6 Opus.