https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/120810
This fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error. >From 7da85184e77da5a6d44a8f14ebd3d38d7af493bb Mon Sep 17 00:00:00 2001 From: Brianna Fan <bf...@apple.com> Date: Fri, 20 Dec 2024 16:26:42 -0800 Subject: [PATCH] [Static analysis] Encodes a filename before inserting it into a URL. This fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error. --- clang/tools/scan-build/bin/scan-build | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build index 37241c6d85c5b2..66a7158062a468 100755 --- a/clang/tools/scan-build/bin/scan-build +++ b/clang/tools/scan-build/bin/scan-build @@ -820,7 +820,8 @@ ENDTEXT } # Emit the "View" link. - print OUT "<td><a href=\"$ReportFile#EndPath\">View Report</a></td>"; + my $EncodedReport = URLEscape($ReportFile); + print OUT "<td><a href=\"$EncodedReport#EndPath\">View Report</a></td>"; # Emit REPORTBUG markers. print OUT "\n<!-- REPORTBUG id=\"$ReportFile\" -->\n"; @@ -1465,6 +1466,17 @@ sub HtmlEscape { return $tmp; } +##----------------------------------------------------------------------------## +# URLEscape - encode characters that are special in URLs +##----------------------------------------------------------------------------## + +sub URLEscape { + my $arg = shift || ''; + my $tmp = $arg; + $tmp =~ s/\+/%2B/g; + return $tmp; +} + ##----------------------------------------------------------------------------## # ShellEscape - backslash escape characters that are special to the shell ##----------------------------------------------------------------------------## _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits