Repository navigation
fix(statechart): keep CDATA comments out of the XML markup - #1222
Open
denis-trofimov wants to merge 1 commit into
Open
denis-trofimov wants to merge 1 commit into
denis-trofimov wants to merge 1 commit into
Conversation
SANY's XMLExporter wraps TLA+ comments in <![CDATA[...]]>. parseXml scanned the raw XML, so a comment containing TLA+ sequence syntax (<<1, 2>>, as in Sequences.tla) desynced the tag stack and the statechart crashed with "Cannot read properties of undefined (reading 'tag')". Escape the CDATA bodies before scanning, and cover it with a test.
Author
|
Hey thanks for skill! @poteto |
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
statechartcrashes on any spec whose SANY XML export contains a comment with TLA+ sequence syntax:SANY's
XMLExporterwraps comments in<![CDATA[...]]>.parseXmlscans the raw XML with a tag regex, so the<</>>inside a CDATA comment (for example<<1, 2>>, as inSequences.tla) are read as markup. The scanner pops the tag stack on a>it should not have seen, and the next element is attached to anundefinedparent.Reproduced with a spec that extends
Sequencesand has any comment containing<<...>>.Fix
parseXmlescapes CDATA bodies — and only them — before scanning, so their contents stay text. Comments keep their text; markup outside CDATA is untouched.Test
test/spec.test.tsfeedsreadSanyan export whosepre-commentscontain(* x > y, then <<1, 2>> and a < b. *)and asserts the variable is still read.npm testinpstack/skills/statechart/scripts: the new test passes.test/render.test.tsfails both on this branch and onmainwithout the change — pre-existing, unrelated.