]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
gen.pl: escape all dashes (ascii minus) to avoid unicode hyphens
authorDaniel Stenberg <daniel@haxx.se>
Wed, 9 Aug 2023 07:00:23 +0000 (09:00 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 9 Aug 2023 07:53:55 +0000 (09:53 +0200)
Reported-by: FC Stegerman
Fixes #11635
Closes #11637

docs/cmdline-opts/gen.pl

index db68d31d4e96f68ad7474b9d47816c2d28cd116d..8542b171309d86d182b378b155c43e5838996b27 100755 (executable)
@@ -68,11 +68,11 @@ sub manpageify {
     my $l;
     if($optlong{$k} ne "") {
         # both short + long
-        $l = "\\fI-".$optlong{$k}.", --$k\\fP";
+        $l = "\\fI-".$optlong{$k}.", \\-\\-$k\\fP";
     }
     else {
         # only long
-        $l = "\\fI--$k\\fP";
+        $l = "\\fI\\-\\-$k\\fP";
     }
     return $l;
 }
@@ -117,8 +117,7 @@ sub printdesc {
             }
         }
         # quote "bare" minuses in the output
-        $d =~ s/( |\\fI|^)--/$1\\-\\-/g;
-        $d =~ s/([ -]|\\fI|^)-/$1\\-/g;
+        $d =~ s/([^\\])-/$1\\-/g;
         # handle single quotes first on the line
         $d =~ s/^(\s*)\'/$1\\(aq/;
         # handle double quotes first on the line
@@ -450,6 +449,7 @@ sub single {
         print "\nExample$s:\n.nf\n";
         foreach my $e (@examples) {
             $e =~ s!\$URL!https://example.com!g;
+            $e =~ s/\-/\\-/g;
             print " curl $e\n";
         }
         print ".fi\n";