loom icon indicating copy to clipboard operation
loom copied to clipboard

loom.io: messed escaping in attributes

Open vtzi opened this issue 10 years ago • 2 comments

The problem happens when an attribute key or value is a collection and has items requiring escaping. Here is small snippet to reproduce it:

(gv/view (-> (gg/graph [1 2]) (ga/add-attr-to-edges :a ["AA."bb""] [[1 2]])))

The problem is in dot-attrs function. str on collection escapes it: user> (str ["AA."bb""]) "["AA.\"bb\""]"

I guess dot-attrs should be fully reworked somehow

vtzi avatar Sep 24 '15 15:09 vtzi

@vtzi can you explain what output you were expecting?

(str ["AA.\"bb\""])
=> "[\"AA.\\\"bb\\\"\"]"
(println "[\"AA.\\\"bb\\\"\"]")
["AA.\"bb\""]
=> nil

This looks like normal Clojure escaping to me?

danielcompton avatar Sep 24 '15 21:09 danielcompton

@danielcompton the output of str is fine. the problem is that loom.io/dot-esc does not escape backslashes and graphviz gets really confused.

Escaping the backslash fixes the issue:

(defn- dot-esc [s](escape s {\ "\" " """ newline "\n"}))

vtzi avatar Sep 25 '15 06:09 vtzi