]> granicus.if.org Git - graphviz/commit
fix erroneous commas in JSON output of graphs with only clusters
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 29 Sep 2022 01:26:34 +0000 (18:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 29 Sep 2022 15:36:31 +0000 (08:36 -0700)
commitd35a9ff59b0cee749572cde1d622a5a4f7fd036a
tree6280938d2f8f8551eae68e9827bd65c064c6d365
parent48b764e79c1f1d66556555e3a8d7fb155870bd47
fix erroneous commas in JSON output of graphs with only clusters

When a graph or subgraph contained exclusively subnodes that were clusters (that
is, it contained a non-zero number of subnodes, but all of them were clusters),
the output of `-Tjson` would contain an extra comma. This malformed JSON could
not be ingested by most downstream parsers.

This appears to have been a mistake in f82c51fc9644047e9ce80d860fea562e98d3311c
that introduced cluster skipping in the loop that emits nodes in JSON. It did
not account for the earlier part of the containing function that was intended to
early-exit if the loop would have a 0 iteration count.

As noted in the discussion of #2282, a couple of the maintainers believe this
manual JSON writing code is inherently fragile and likely contains more latent
bugs. But we do not have maintainer consensus on migrating to an established
JSON-writing library. This fix attempts to surgically address the current known
bug. But I cannot guarantee it does not introduce others.

Gitlab: fixes #2282
CHANGELOG.md
plugin/core/gvrender_core_json.c
tests/test_regression.py