diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d5e8e..ffec0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ New Features: Bug Fixes: -* Fixed an invalid method call in `bgv2json` (#82, @nirvdrum). +* Fixed an invalid method call in `bgv2json` (#79, @nirvdrum). +* Fixed a character escape issue with the Mermaid formatter that could result in invalid syntax (#87, @nirvdrum). Changes: @@ -28,7 +29,7 @@ Changes: * Removed hidden nodes from the `describe` command output (#66, @chrisseaton). * Improved the `describe` command output to ignore hidden nodes (@chrisseaton). * Added more “triggers” to detect if we’re looking at Graal or Truffle graphs (as opposed to regular JVM graphs) (@chrisseaton). -* Support simplifying more allocation node classes (#73, @nirvdrum). +* Support simplifying more allocation node classes (#67, @nirvdrum). # 0.14 diff --git a/lib/seafoam/mermaid_writer.rb b/lib/seafoam/mermaid_writer.rb index ae58c35..807a3ee 100644 --- a/lib/seafoam/mermaid_writer.rb +++ b/lib/seafoam/mermaid_writer.rb @@ -38,7 +38,7 @@ def output_node(indent, id, attrs) when "diamond" shape = ["{{", "}}"] end - @stream.puts "#{indent}#{id}#{shape[0]}#{attrs[:label].inspect}#{shape[1]}" + @stream.puts "#{indent}#{id}#{shape[0]}#{attrs[:label].gsub('"', "#quot;").inspect}#{shape[1]}" @stream.puts "#{indent}style #{id} fill:#{attrs[:fillcolor]},stroke:#{attrs[:color]},color:#{attrs[:fontcolor]};" end diff --git a/spec/seafoam/mermaid_write_spec.rb b/spec/seafoam/mermaid_write_spec.rb index ec98093..d2946a2 100644 --- a/spec/seafoam/mermaid_write_spec.rb +++ b/spec/seafoam/mermaid_write_spec.rb @@ -44,5 +44,20 @@ end end end + + it "escapes quotes in labels" do + attrs = { + color: "black", + fillcolor: "#f9f9f9", + fontcolor: "#1a1919", + fontname: "Arial", + label: "\"abc\"", + shape: "rectangle", + style: "filled", + } + + @writer.send(:output_node, "", "node0", attrs) + expect(@stream.string).to(include("node0(\"#quot;abc#quot;\")")) + end end end