mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
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"
This commit is contained in:
parent
75a56cb632
commit
d498347a01
@ -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 = ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user