From 755e780c6cc64a880acfcdd70d4d76be9468ac72 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 21 Mar 2024 12:20:42 -0400 Subject: [PATCH 1/2] Fix a character escape issue with the Mermaid formatter that could result in invalid syntax. --- CHANGELOG.md | 1 + lib/seafoam/mermaid_writer.rb | 2 +- spec/seafoam/mermaid_write_spec.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d5e8e..1405756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ New Features: Bug Fixes: * Fixed an invalid method call in `bgv2json` (#82, @nirvdrum). +* Fixed a character escape issue with the Mermaid formatter that could result in invalid syntax (#87, @nirvdrum). Changes: 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 From fa324b64558247f73a764232a42f590233010b4e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 21 Mar 2024 12:26:08 -0400 Subject: [PATCH 2/2] Fix some changelog issue references. We should point at reported issues rather than PRs. An inquisitive reader can follow the issue to the changeset if desired. --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1405756..ffec0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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: @@ -29,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