]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mdlinkcheck: pass curl arguments to `open()` as list
authorViktor Szakats <commit@vsz.me>
Mon, 10 Nov 2025 00:27:25 +0000 (01:27 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 10 Nov 2025 13:21:35 +0000 (14:21 +0100)
To prevent misinterpreting quotes or other special characters.

Requires Perl 5.22+ (2015-Jun-01) on Windows.

Ref: https://perldoc.perl.org/functions/open

Closes #19437

scripts/mdlinkcheck

index bbd6ac46022bd7bcaa28ae3fd46987ea06766ae1..842f0c97665897c96718427fb21108ed73a742b9 100755 (executable)
@@ -138,13 +138,17 @@ sub checkurl {
     }
 
     print "check $url\n";
-    my $curlcmd="curl -ILfsm10 --retry 2 --retry-delay 5 -A \"Mozilla/curl.se link-probe\"";
     $url =~ s/\+/%2B/g;
-    if($url =~ /[\"\'\n]/) {
-        print STDERR "Bad URL in markdown: %s\n", $url{$url};
+    my @content;
+    if(open(my $fh, '-|', 'curl', '-ILfsm10', '--retry', '2', '--retry-delay', '5',
+                          '-A', 'Mozilla/curl.se link-probe', $url)) {
+        @content = <$fh>;
+        close $fh;
+    }
+    else {
+        print STDERR "FAIL\n";
         return 1; # fail
     }
-    my @content = `$curlcmd \"$url\"`;
     if(!$content[0]) {
         print STDERR "FAIL\n";
         return 1; # fail