From 27e2779beddd45ee22a5493b49ee9bc1cd0f844a Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Tue, 27 Feb 2018 16:11:38 -0800 Subject: [PATCH] rule-syntax-check: fix handling of runaway strings in comma splitting (#8298) A runaway string should still be returned by the code that splits on commas, so add a '?' to the regex so that the last '"?' in a string still produces a valid block for the split code. Tested: ACTION=="remove\"GOTO="" Which then produced: $ test/rule-syntax-check.py src/login/70-uaccess.rules # looking at src/login/70-uaccess.rules Invalid line src/login/70-uaccess.rules:10: ACTION=="remove\"GOTO="" clause: ACTION=="remove\"GOTO="" --- test/rule-syntax-check.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 7ee34eb700..a245432b62 100755 --- a/test/rule-syntax-check.py +++ b/test/rule-syntax-check.py @@ -34,7 +34,9 @@ args_tests = re.compile(r'(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*' no_args_assign = re.compile(r'(NAME|SYMLINK|OWNER|GROUP|MODE|TAG|RUN|LABEL|GOTO|OPTIONS|IMPORT)\s*(?:\+=|:=|=)\s*' + quoted_string_re + '$') args_assign = re.compile(r'(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\s*' + quoted_string_re + '$') # Find comma-separated groups, but allow commas that are inside quoted strings. -comma_separated_group_re = re.compile(r'(?:[^,"]|' + quoted_string_re + ')+') +# Using quoted_string_re + '?' so that strings missing the last double quote +# will still match for this part that splits on commas. +comma_separated_group_re = re.compile(r'(?:[^,"]|' + quoted_string_re + '?)+') result = 0 buffer = '' -- 2.25.1