=== modified file 'TODO' --- TODO 2019-04-09 19:41:53 +0000 +++ TODO 2020-02-08 14:01:38 +0000 @@ -82,8 +82,6 @@ ** TODO Error handling on error parsing config files ** TODO init.d script error handling ** TODO D-Bus server properties; address, port, interface, etc. :2: -** Python 3 :2: -*** TODO [#C] In Python 3.3, use shlex.quote() instead of re.escape() * mandos-ctl ** TODO Remove old string_to_delta format :2: === modified file 'mandos' --- mandos 2020-02-06 15:56:51 +0000 +++ mandos 2020-02-08 14:01:38 +0000 @@ -79,6 +79,7 @@ import codecs import unittest import random +import shlex import dbus import dbus.service @@ -103,6 +104,12 @@ collections.abc = abc del abc +# Add shlex.quote if it does not exist +try: + shlex.quote +except AttributeError: + shlex.quote = re.escape + # Show warnings by default if not sys.warnoptions: import warnings @@ -1127,7 +1134,7 @@ if self.checker is None: # Escape attributes for the shell escaped_attrs = { - attr: re.escape(str(getattr(self, attr))) + attr: shlex.quote(str(getattr(self, attr))) for attr in self.runtime_expansions} try: command = self.checker_command % escaped_attrs