From 77be4a7ab2b5a0c633b9107fd286bda1f57e4725 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 10 Nov 2025 01:27:25 +0100 Subject: [PATCH] mdlinkcheck: pass curl arguments to `open()` as list 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index bbd6ac4602..842f0c9766 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -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 -- 2.47.3