]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rule-syntax-check: values can contain escaped double quotes 8269/head
authorFranck Bui <fbui@suse.com>
Fri, 23 Feb 2018 16:12:50 +0000 (17:12 +0100)
committerFranck Bui <fbui@suse.com>
Tue, 27 Feb 2018 13:42:09 +0000 (14:42 +0100)
This is true since commit 7e760b79ad143b26a5c937afa7666a7c40508f85.

Note that the changes in the regex expressions relies on the fact that the
script assumes that the comma separator is mandatory.

Add a comment in the script to clarify this.

test/rule-syntax-check.py

index f24285ddac68b4fa32ba0b5751e58114ae0cfe0f..dcbab5fc6dcbb8e9f1957689393757b9b3567000 100755 (executable)
@@ -28,10 +28,10 @@ rules_files = sys.argv[1:]
 if not rules_files:
     sys.exit('Specify files to test as arguments')
 
-no_args_tests = re.compile(r'(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|PROGRAM|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$')
-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*"([^"]*)"$')
-args_assign = re.compile(r'(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\s*"([^"]*)"$')
+no_args_tests = re.compile(r'(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|PROGRAM|RESULT|TEST)\s*(?:=|!)=\s*"(.*)"$')
+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*"(.*)"$')
+args_assign = re.compile(r'(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\s*"(.*)"$')
 
 result = 0
 buffer = ''
@@ -54,6 +54,8 @@ for path in rules_files:
         if not line or line.startswith('#'):
             continue
 
+        # Separator ',' is normally optional but we make it mandatory here as
+        # it generally improves the readability of the rules.
         for clause in line.split(','):
             clause = clause.strip()
             if not (no_args_tests.match(clause) or args_tests.match(clause) or