mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
rule-syntax-check: values can contain escaped double quotes
This is true since commit 7e760b79ad.
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user