mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Handle whitespace, add separator to regex in set_directive_lines
We added the separator to the regex in set_directive_lines to avoid grabbing just a prefix. This doesn't allow for whitespace around the separator. For the Apache case we expected that the separator would be just spaces but it can also use tabs (like Ubuntu 18). Add a special case so that passing in a space separator is treated as whitespace (tab or space). https://pagure.io/freeipa/issue/7490 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
committed by
Florence Blanc-Renaud
parent
0653d2a17e
commit
ae6c8d2c7a
@@ -565,11 +565,15 @@ def set_directive_lines(quotes, separator, k, v, lines, comment):
|
||||
v_quoted = quote_directive_value(v, '"') if quotes else v
|
||||
new_line = ''.join([k, separator, v_quoted, '\n'])
|
||||
|
||||
# Special case: consider space as "white space" so tabs are allowed
|
||||
if separator == ' ':
|
||||
separator = '[ \t]+'
|
||||
|
||||
found = False
|
||||
addnext = False # add on next line, found a comment
|
||||
matcher = re.compile(r'\s*{}'.format(re.escape(k + separator)))
|
||||
cmatcher = re.compile(r'\s*{}\s*{}'.format(comment,
|
||||
re.escape(k + separator)))
|
||||
matcher = re.compile(r'\s*{}\s*{}'.format(re.escape(k), separator))
|
||||
cmatcher = re.compile(r'\s*{}\s*{}\s*{}'.format(comment,
|
||||
re.escape(k), separator))
|
||||
for line in lines:
|
||||
if matcher.match(line):
|
||||
found = True
|
||||
|
||||
Reference in New Issue
Block a user