Commit 6573b681 authored by Jérome Perrin's avatar Jérome Perrin

fixup! apachedex: fix argument parsing

keep consistency with escaping rules regarding \

Using shlex escapes \, which we don't want here.
parent 70293e95
Pipeline #12240 failed with stage
in 0 seconds
......@@ -61,7 +61,10 @@ def build_command(apachedex_executable, output_file,
raise ValueError("log_list: no log files to analyse were provided")
if config:
argument_list.extend(shlex.split(config))
lexer = shlex.shlex(config, posix=True)
lexer.whitespace_split = True
lexer.escape = '' # don't escape \
argument_list.extend(list(lexer))
argument_list.append('--error-detail')
argument_list += log_list
......
......@@ -65,7 +65,7 @@ class TestApachedexCommand(unittest.TestCase):
'--default', 'foo',
'--error-detail', self.acesslog1, self.acesslog2 ])
def test_complexCommandEscape(self):
def test_complexCommandDoubleQuoteEscape(self):
command = build_command(self.apachedex,
'bar.html',
[self.acesslog1, self.acesslog2],
......@@ -77,6 +77,18 @@ class TestApachedexCommand(unittest.TestCase):
'--base', 'foo bar',
'--error-detail', self.acesslog1, self.acesslog2 ])
def test_complexCommandBackslashEscape(self):
command = build_command(self.apachedex,
'bar.html',
[self.acesslog1, self.acesslog2],
r'--base +erp5 .*/VirtualHostRoot/erp5(/|\?|$)')
self.assertEqual(command, ['/bin/apachedex',
'--js-embed',
'--out', 'bar.html',
'--base', '+erp5', r'.*/VirtualHostRoot/erp5(/|\?|$)',
'--error-detail', self.acesslog1, self.acesslog2 ])
def test_raiseErro(self):
self.assertRaises(ValueError, build_command, self.apachedex, 'foo.html', [])
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment