From: Filipe Brandenburger Date: Wed, 28 Feb 2018 00:11:38 +0000 (-0800) Subject: rule-syntax-check: fix handling of runaway strings in comma splitting (#8298) X-Git-Tag: v238~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e2779beddd45ee22a5493b49ee9bc1cd0f844a;p=thirdparty%2Fsystemd.git 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="" --- diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 7ee34eb7002..a245432b62c 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 = ''