agxset(g, xd->g_draw, agxbuse(xbufs[EMIT_GDRAW]));
}
if (GD_label(g))
- agxset(g, xd->g_l_draw, agxbuse(xbufs[EMIT_GLABEL]));
+ put_escaping_backslashes(g, xd->g_l_draw, agxbuse(xbufs[EMIT_GLABEL]));
agsafeset (g, "xdotversion", xd->version_s, "");
for (i = 0; i < NUMXBUFS; i++)
assert any(r'hello \\\" world' in l for l in ldraw), \
'unexpected ldraw contents'
+def test_165_3():
+ '''
+ variant of test_165() that checks a similar problem for graph labels
+ https://gitlab.com/graphviz/graphviz/-/issues/165
+ '''
+
+ # locate our associated test case in this directory
+ input = os.path.join(os.path.dirname(__file__), '165_3.dot')
+ assert os.path.exists(input), 'unexpectedly missing test case'
+
+ # ask Graphviz to translate it to xdot
+ output = subprocess.check_output(['dot', '-Txdot', input],
+ universal_newlines=True)
+
+ # find the lines containing _ldraw_ attributes
+ ldraw = re.findall(r'^\s*_ldraw_\s*=(.*?)$', output, re.MULTILINE)
+ assert ldraw is not None, 'no _ldraw_ attributes in graph'
+
+ # one of these should contain the label correctly escaped
+ assert any(r'hello \\\" world' in l for l in ldraw), \
+ 'unexpected ldraw contents'
+
def test_1436():
'''
test a segfault from https://gitlab.com/graphviz/graphviz/-/issues/1436 has