summaryrefslogtreecommitdiff
path: root/test/rule-syntax-check.py
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2018-02-27 11:12:18 -0800
committerFilipe Brandenburger <filbranden@google.com>2018-02-27 11:15:42 -0800
commitd498347a01266fc77ad9086611495802096d00f6 (patch)
tree31559e03eb2f694f55c0b8ff63d7c8779645f640 /test/rule-syntax-check.py
parent75a56cb63259505e568d0524461d446040ceba6c (diff)
downloadsystemd-d498347a01266fc77ad9086611495802096d00f6.tar.gz
rule-syntax-check: add support for escaped double quotes
Add support to backslash-escaped double quote inside a string. Tested by modifying src/login/70-uaccess.rules to include: ACTION=="remove" it", GOTO="uaccess_end" And had the rule checker complain about it: $ 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" it", GOTO="uaccess_end" clause: ACTION=="remove" it"
Diffstat (limited to 'test/rule-syntax-check.py')
-rwxr-xr-xtest/rule-syntax-check.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py
index dcbab5fc6d..1a58d17328 100755
--- a/test/rule-syntax-check.py
+++ b/test/rule-syntax-check.py
@@ -28,10 +28,11 @@ 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*"(.*)"$')
+quoted_string_re = r'"(?:[^\\"]|\\.)*"'
+no_args_tests = re.compile(r'(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|PROGRAM|RESULT|TEST)\s*(?:=|!)=\s*' + quoted_string_re + '$')
+args_tests = re.compile(r'(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*' + quoted_string_re + '$')
+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 + '$')
result = 0
buffer = ''