Skip to content

Commit 7da8518

Browse files
briannafanrniwa
authored andcommitted
[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.
1 parent fecf139 commit 7da8518

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 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,17 @@ 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+
my $tmp = $arg;
1476+
$tmp =~ s/\+/%2B/g;
1477+
return $tmp;
1478+
}
1479+
14681480
##----------------------------------------------------------------------------##
14691481
# ShellEscape - backslash escape characters that are special to the shell
14701482
##----------------------------------------------------------------------------##

0 commit comments

Comments
 (0)