Skip to content

Commit 6f9596b

Browse files
committed
Properly escape TLA+ tuples ("<<" and ">>") in SVG output.
[Bug]
1 parent 89d8cf9 commit 6f9596b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

modules/tlc2/overrides/SVG.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public static Value SVGElemToString(Value elem) throws Exception {
133133
// explicitly disallow it.
134134
StringValue innerTextVal = (StringValue) frv.apply(new StringValue("innerText"), 0);
135135
String innerText = innerTextVal.getVal().toString();
136+
// Make sure TLA+ tuples such as <<1,2,3>> get properly rendered.
137+
innerText = innerText.replaceAll("<<", "&lt;&lt;").replaceAll(">>", "&gt;&gt;");
136138

137139
// Produce the SVG element string.
138140
String svg = String.format("<%s%s>", name, attrStr);

tests/SVGTests.tla

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,10 @@ ASSUME(
133133
3 :> [x |-> 16, y |-> 9 ] )
134134
)
135135

136+
ASSUME(LET
137+
elem == Text(0, 0, ToString(<<1,2,3>>), <<>>)
138+
IN
139+
AssertEq(SVGElemToString(elem), "<text x='0' y='0'>&lt;&lt;1, 2, 3&gt;&gt;</text>"))
140+
141+
136142
=============================================================================

0 commit comments

Comments
 (0)