Fix for videos with double quotes in the title

This commit is contained in:
Mattéo Delabre 2020-11-27 22:24:40 +01:00
parent e352cca4d8
commit e2514185e8
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,11 @@ const GRAPH_NODE = ' "%s" [label="%s"]';
const GRAPH_NODE_URL = ' "%s" [label="%s", URL="%s", fontcolor=blue]';
const GRAPH_LINK = ' "%s" -> "%s"';
/**
* Escape double quotes in a string.
*/
const escapeQuotes = str => str.replace(/"/g, '\\"');
/**
* Convert a graph to the DOT format.
*
@ -27,11 +32,11 @@ export const graphToDOT = (graph, title = id => id, url = () => '') =>
if (url === '')
{
return util.format(GRAPH_NODE, id, nodeTitle);
return util.format(GRAPH_NODE, id, escapeQuotes(nodeTitle));
}
else
{
return util.format(GRAPH_NODE_URL, id, nodeTitle, nodeUrl);
return util.format(GRAPH_NODE_URL, id, escapeQuotes(nodeTitle), nodeUrl);
}
}
).join('\n');