Skip to content

Commit 04383d6

Browse files
rniwabriannafan
andauthored
[Static analysis] Encodes a filename before inserting it into a URL. (#120810)
This fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error. --------- Co-authored-by: Brianna Fan <[email protected]>
1 parent 8f18f36 commit 04383d6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

clang/tools/scan-build/bin/scan-build

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ ENDTEXT
820820
}
821821

822822
# Emit the "View" link.
823-
print OUT "<td><a href=\"$ReportFile#EndPath\">View Report</a></td>";
823+
my $EncodedReport = URLEscape($ReportFile);
824+
print OUT "<td><a href=\"$EncodedReport#EndPath\">View Report</a></td>";
824825

825826
# Emit REPORTBUG markers.
826827
print OUT "\n<!-- REPORTBUG id=\"$ReportFile\" -->\n";
@@ -1465,6 +1466,16 @@ sub HtmlEscape {
14651466
return $tmp;
14661467
}
14671468

1469+
##----------------------------------------------------------------------------##
1470+
# URLEscape - encode characters that are special in URLs
1471+
##----------------------------------------------------------------------------##
1472+
1473+
sub URLEscape {
1474+
my $arg = shift || '';
1475+
$arg =~ s/\+/%2B/g;
1476+
return $arg;
1477+
}
1478+
14681479
##----------------------------------------------------------------------------##
14691480
# ShellEscape - backslash escape characters that are special to the shell
14701481
##----------------------------------------------------------------------------##

0 commit comments

Comments
 (0)