From 2150241f101d87a971ef6b4d12b9edb47b3bf174 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 29 Jan 2021 19:01:34 -0800 Subject: [PATCH] fix: no longer lose \n within quoted strings 9bdd24cae96d01fc6b2a940bc87d27edeb5d84a7 addressed a problem where line number tracking was not working across new line characters embedded within quoted strings. However it accidentally unmasked another bug involving a parsing rule that swallowed new lines which was incorrectly enabled within quoted strings. Fixes #1931. --- CHANGELOG.md | 1 + lib/cgraph/scan.l | 3 ++- rtest/test_regression.py | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 853e75370..270014ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Out-of-bounds write caused by incorrect error handling of malloc in genUserdata #1928 - Offer .tar.xz files too #454 - Header file graphviz_version.h has no include guards #1929 +- regression: newlines embedded in quoted labels / node names are not preserved in 2.46.0 #1931 ## [2.46.0] - 2021-01-18 diff --git a/lib/cgraph/scan.l b/lib/cgraph/scan.l index 3f80f8c7e..7845ea1b6 100644 --- a/lib/cgraph/scan.l +++ b/lib/cgraph/scan.l @@ -201,7 +201,7 @@ ID ({NAME}|{NUMBER}) %x hstring %% {GRAPH_EOF_TOKEN} return(EOF); -\n line_num++; +\n line_num++; "/*" BEGIN(comment); [^*\n]* /* eat anything not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ @@ -226,6 +226,7 @@ ID ({NAME}|{NUMBER}) [\\]["] addstr ("\""); [\\][\\] addstr ("\\\\"); [\\][\n] line_num++; /* ignore escaped newlines */ +[\n] addstr ("\n"); line_num++; ([^"\\\n]*|[\\]) addstr(aagtext); [<] BEGIN(hstring); html_nest = 1; beginstr(); [>] html_nest--; if (html_nest) addstr(aagtext); else {BEGIN(INITIAL); endstr_html(); return (T_qatom);} diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 2a9d5c79f..46650af6c 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -719,7 +719,6 @@ def test_1913(): _, stderr = run(graph.format(input)) assert 'Warning: Illegal value {} for ALIGN - ignored'.format(input) in stderr -@pytest.mark.xfail(strict=True) def test_1931(): ''' New lines within strings should not be discarded during parsing -- 2.40.0