Labels can be either plain text or HTML-like labels (`<`, `>` delimited). When
parsing an HTML-like label, the lexer would return the same result for a warning
or an error. This meant the caller would attempt to fallback to a plain text
label in either case. But when the HTML lexer has errored, the input has been
determined unparseable. Falling back to parsing a plain text label is unlikely
to work, and even if it does it produces something that is certainly not what
the user intended. In most scenarios, this fallback behavior would go onto to
crash messily, now that labels were populated with garbage data.
This change simply teaches the calling code to notice the error and exit instead
of falling back. Exiting from within library code like this is not particularly
clean or desirable, but there is no easy elegant error path from this code.
Gitlab: fixes #1311
Reported-by: Google Autofuzz project
SVG. #799
- Legacy man page references to `dotty` have been removed. `dotty` was removed
in Graphviz 4.0.0.
+- Graphviz will now exit when encountering a syntactically invalid HTML label
+ instead of attempting to recover and continue. #1311
### Fixed
int clearHTMLlexer()
{
#ifdef HAVE_EXPAT
- int rv = state.warn | state.error;
+ int rv = state.error ? 3 : state.warn;
XML_ParserFree(state.parser);
agxbfree (&state.lb);
return rv;
/* parseHTML:
* Return parsed label or NULL if failure.
- * Set warn to 0 on success; 1 for warning message; 2 if no expat.
+ * Set warn to 0 on success; 1 for warning message; 2 if no expat; 3 for error
+ * message.
*/
htmllabel_t*
parseHTML (char* txt, int* warn, htmlenv_t *env)
#include <common/intset.h>
#include <cdt/cdt.h>
#include <cgraph/alloc.h>
+#include <cgraph/exit.h>
#include <cgraph/itos.h>
#include <cgraph/strcasecmp.h>
#include <stddef.h>
env.finfo.flags = 0;
lbl = parseHTML(lp->text, &rv, &env);
if (!lbl) {
+ if (rv == 3) {
+ // fatal error
+ graphviz_exit(EXIT_FAILURE);
+ }
/* Parse of label failed; revert to simple text label */
agxbuf xb;
char buf[SMALLBUF];