Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect text node escaping #513

Open
vit9696 opened this issue Feb 8, 2024 · 0 comments
Open

Incorrect text node escaping #513

vit9696 opened this issue Feb 8, 2024 · 0 comments

Comments

@vit9696
Copy link

vit9696 commented Feb 8, 2024

Running the following code sample with:

  • Python 3.11.6
  • graphviz 9.0.0 (20230911.1827)
  • pygraphviz 1.12
import sys
import pygraphviz

G = pygraphviz.AGraph(strict=False, directed=True, name="TEST", fontsize=11.0)

label = 'Test Test test test test test testtest test\l"test test test test test test test test'

n = G.add_node("TESTTEST", label=label, tooltip="", shape="rectangle", style="solid")
G.layout(prog='dot')
G.draw(sys.stdout.buffer, format='svg')

Produces the following error:

Traceback (most recent call last):
  File "/t.py", line 10, in <module>
    G.layout(prog='dot')
  File "/usr/local/lib/python3.11/site-packages/pygraphviz/agraph.py", line 1483, in layout
    data = self._run_prog(prog, " ".join([args, "-T", output_fmt]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pygraphviz/agraph.py", line 1404, in _run_prog
    raise OSError(b"".join(errors).decode(self.encoding))
OSError: Error: <stdin>: syntax error in line 4 near 'test'

Debugging shows that the issue is apparently caused by unescaped quote during the layout process:

digraph TEST {
	graph [fontsize=11.0];
	node [label="\N"];
	TESTTEST	[label="Test Test test test test test testtest test\l"test test test test test test test test",
		shape=rectangle,
		style=solid];
}

Reproduced on macOS and Arch Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant