internal/graph: escape double quotes in tag names in DOT output#1008
Open
LeSingh1 wants to merge 1 commit into
Open
internal/graph: escape double quotes in tag names in DOT output#1008LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
Tag (nodelet) labels interpolated t.Name directly into the DOT label="..." attribute without escaping, unlike node and edge labels which use escapeForDot. A tag name containing a double quote (common in CPU profile string tags) produced invalid DOT that graphviz could not render. Apply escapeForDot to tag names in both the label-tag and numeric-nodelet paths. Fixes google#769
Collaborator
|
It doesn't look like the proto "officially" disallows double-quote characters in the label/tag names, but it's pretty odd to have them there. What is the use case for this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #769
Problem
Tag (nodelet) labels in the DOT renderer interpolate the tag name directly into the
label = "..."attribute without escaping:Every other label in
dotgraph.go(node names, edge labels, legend title) is passed throughescapeForDot, but the two tag-nodelet paths were not. A tag name containing a double quote — common in CPU-profile string tags, e.g.range_str:.../"{...}"— produces invalid DOT that graphviz cannot render, breaking the whole graph (see the example in #769).Fix
Apply the existing
escapeForDothelper tot.Namein both the label-tag path (tagsToNodelets) and the numeric-nodelet path (numericNodelets). No other behavior changes.Test
Added
TestComposeWithTagsThatNeedEscaping(goldencompose10.dot): a label tag whose name contains"now renders aslabel = "range_str:\"{quote}\"". The test fails before this change (unescaped quote → malformed DOT) and passes after. Fullinternal/graphpackage tests pass;go vetandgofmtare clean.