From c684c2510b51b8ada895571ad9c461b0cee20a25 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 25 Sep 2021 11:08:09 -0700 Subject: [PATCH] add a test case for invalid GML output Related to #1276. --- rtest/test_regression.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 2de94e394..f48262be0 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -344,6 +344,34 @@ def test_1221(): # process this with dot subprocess.check_call(["dot", "-Tsvg", "-o", os.devnull, input]) +@pytest.mark.skipif(shutil.which("gv2gml") is None, + reason="gv2gml not available") +@pytest.mark.xfail(strict=True) +def test_1276(): + """ + quotes within a label should be escaped in translation to GML + https://gitlab.com/graphviz/graphviz/-/issues/1276 + """ + + # DOT input containing a label with quotes + dot = 'digraph test {\n' \ + ' x[label=<"Label">];\n' \ + '}' + + # process this to GML + p = subprocess.Popen(["gv2gml"], stdin=subprocess.PIPE, + stdout=subprocess.PIPE, universal_newlines=True) + gml, _ = p.communicate(dot) + + assert p.returncode == 0, "gv2gml failed" + + # the unescaped label should not appear in the output + assert '""Label""' not in gml, "quotes not escaped in label" + + # the escaped label should appear in the output + assert '""Label""' in gml or '""Label""' in gml, \ + "escaped label not found in GML output" + def test_1314(): """ test that a large font size that produces an overflow in Pango is rejected -- 2.40.0