]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cd2nroff: fix backslashes for 4-space indent lines
authorDaniel Stenberg <daniel@haxx.se>
Sat, 25 Jul 2026 20:22:21 +0000 (22:22 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 25 Jul 2026 20:59:55 +0000 (22:59 +0200)
They were previously only properly escaped for ~~~ quotes. Spotted for
the CURLOPT_HTTPSIG_KEY man page.

Closes #22393

scripts/cd2nroff

index 3f5a447929c8bfb95f3fc7f5a1278aa329fbe2d1..02f97bc41efcffe62ac292034a7c9c6d3fcb4413 100755 (executable)
@@ -200,6 +200,17 @@ my %knowntls = (
     'none' => 1,
     );
 
+sub quoted {
+    my ($d) = @_;
+
+    # in verbatim/quoted blocks, make backslashes literal
+    $d =~ s/\\/\\\\/g;
+
+    # lines starting with a period or apostrophe need it escaped
+    $d =~ s/^([.'])/\\&$1/;
+    return $d;
+}
+
 sub single {
     my @seealso;
     my @proto;
@@ -391,28 +402,27 @@ sub single {
             if($quote == 4) {
                 # remove the indentation
                 if($d =~ /^    (.*)/) {
-                    push @desc, "$1\n";
+                    $d = quoted($1);
+                    push @desc, "$d\n";
                     next;
                 }
-                else {
+                # end of quote
+                $quote = 0;
+                push @desc, ".fi\n";
+
+                # fall-through
+            }
+            else {
+                if(/^~~~/) {
                     # end of quote
                     $quote = 0;
                     push @desc, ".fi\n";
                     next;
                 }
-            }
-            if(/^~~~/) {
-                # end of quote
-                $quote = 0;
-                push @desc, ".fi\n";
+                $d = quoted($d);
+                push @desc, $d;
                 next;
             }
-            # convert single backslashes to doubles
-            $d =~ s/\\/\\\\/g;
-            # lines starting with a period needs it escaped
-            $d =~ s/^\./\\&./;
-            push @desc, $d;
-            next;
         }
 
         # remove single line HTML comments
@@ -512,7 +522,8 @@ sub single {
             $quote = 4;
             push @desc, "\n" if($blankline && !$header);
             $header = 0;
-            push @desc, ".nf\n$1\n";
+            my $d = quoted($1);
+            push @desc, ".nf\n$d\n";
         }
         elsif(/^[ \t]*\n/) {
             # count and ignore blank lines