diff --git a/internal/graph/dotgraph.go b/internal/graph/dotgraph.go index d704fc4e13..873aa62313 100644 --- a/internal/graph/dotgraph.go +++ b/internal/graph/dotgraph.go @@ -390,7 +390,7 @@ func multilinePrintableName(info *NodeInfo) string { infoCopy.Name = strings.ReplaceAll(infoCopy.Name, "[...]", "[…]") infoCopy.Name = strings.ReplaceAll(infoCopy.Name, ".", `\n`) if infoCopy.File != "" { - infoCopy.File = filepath.Base(infoCopy.File) + infoCopy.File = escapeForDot(filepath.Base(infoCopy.File)) } return strings.Join(infoCopy.NameComponents(), `\n`) + `\n` } diff --git a/internal/graph/dotgraph_test.go b/internal/graph/dotgraph_test.go index b375bb6225..1a7444b396 100644 --- a/internal/graph/dotgraph_test.go +++ b/internal/graph/dotgraph_test.go @@ -141,7 +141,7 @@ func TestComposeWithStandardGraphAndURL(t *testing.T) { func TestComposeWithNamesThatNeedEscaping(t *testing.T) { g := baseGraph() a, c := baseAttrsAndConfig() - g.Nodes[0].Info = NodeInfo{Name: `var"src"`} + g.Nodes[0].Info = NodeInfo{Name: `var"src"`, File: `src/file"name.cc`, Lineno: 10, Columnno: 2} g.Nodes[1].Info = NodeInfo{Name: `var"#dest#"`} var buf bytes.Buffer diff --git a/internal/graph/testdata/compose7.dot b/internal/graph/testdata/compose7.dot index 8f749a7797..f83dc084bd 100644 --- a/internal/graph/testdata/compose7.dot +++ b/internal/graph/testdata/compose7.dot @@ -1,7 +1,7 @@ digraph "testtitle" { node [style=filled fillcolor="#f8f8f8"] subgraph cluster_L { "label1" [shape=box fontsize=16 label="label1\llabel2\llabel3: \"foo\"\l" tooltip="testtitle"] } -N1 [label="var\"src\"\n10 (10.00%)\nof 25 (25.00%)" id="node1" fontsize=22 shape=box tooltip="var\"src\" (25)" color="#b23c00" fillcolor="#edddd5"] +N1 [label="var\"src\"\nfile\"name.cc:10:2\n10 (10.00%)\nof 25 (25.00%)" id="node1" fontsize=22 shape=box tooltip="var\"src\" src/file\"name.cc:10:2 (25)" color="#b23c00" fillcolor="#edddd5"] N2 [label="var\"#dest#\"\n15 (15.00%)\nof 25 (25.00%)" id="node2" fontsize=24 shape=box tooltip="var\"#dest#\" (25)" color="#b23c00" fillcolor="#edddd5"] -N1 -> N2 [label=" 10" weight=11 color="#b28559" tooltip="var\"src\" -> var\"#dest#\" (10)" labeltooltip="var\"src\" -> var\"#dest#\" (10)"] +N1 -> N2 [label=" 10" weight=11 color="#b28559" tooltip="var\"src\" src/file\"name.cc:10:2 -> var\"#dest#\" (10)" labeltooltip="var\"src\" src/file\"name.cc:10:2 -> var\"#dest#\" (10)"] }