]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
conf: Escape " and \ in man page output
authorTobias Brunner <tobias@strongswan.org>
Wed, 16 Apr 2025 13:30:35 +0000 (15:30 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 28 May 2025 07:58:17 +0000 (09:58 +0200)
conf/format-options.py

index e0fa180552ca169d8f714e31aec51bb06327cba2..176a3837ca567e535c2ee7e9db3263caf0a99dfa 100755 (executable)
@@ -241,6 +241,7 @@ class GroffTagReplacer(TagReplacer):
                        if not punct:
                                punct = ''
                        text = re.sub(r'[\r\n\t]', ' ', m.group('text'))
+                       text = re.sub(r'"', '""', text)
                        return '{0}.R{1} "{2}" "{3}" "{4}"\n'.format(nl, format, brack, text, punct)
                return replacer
 
@@ -305,7 +306,8 @@ class ManFormatter:
        def __groffize(self, text):
                """Encode text as groff text"""
                text = self.__tags.replace(text)
-               text = re.sub(r'(?<!\\)-', r'\\-', text)
+               text = re.sub(r'\\(?!-)', '\\[rs]', text)
+               text = re.sub(r'(?<!\\)-', '\\-', text)
                # remove any leading whitespace
                return re.sub(r'^\s+', '', text, flags = re.MULTILINE)