Skip to content

Commit

Permalink
Escape quote character into " when sanitizing HTML
Browse files Browse the repository at this point in the history
Some ops have quotes in their metadata and if not escaped these lead to errors when rendering a dot graph.

PiperOrigin-RevId: 631544105
  • Loading branch information
tensorflower-gardener committed May 7, 2024
1 parent 2100915 commit 027d6b3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions third_party/xla/xla/service/hlo_graph_dumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ std::string NodeColorAttributes(ColorScheme color) {
node_colors.stroke_color, node_colors.fill_color);
}

// Replaces <> with &lt;&gt;, so that this string is safe(er) for use in a
// graphviz HTML-like string.
// Replaces <> with &lt;&gt; and " with &quot;, so that this string is safe(er)
// for use in a graphviz HTML-like string.
std::string HtmlLikeStringSanitize(absl::string_view s) {
return absl::StrReplaceAll(s, {{"<", "&lt;"}, {">", "&gt;"}});
return absl::StrReplaceAll(s,
{{"<", "&lt;"}, {">", "&gt;"}, {"\"", "&quot;"}});
}

bool IsFusedBroadcastOfConstantEffectiveScalar(const HloInstruction* instr) {
Expand Down

0 comments on commit 027d6b3

Please sign in to comment.