-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Static analysis] Encodes a filename before inserting it into a URL. #120810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Static analysis] Encodes a filename before inserting it into a URL. #120810
Conversation
This fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error.
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) ChangesThis fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error. Full diff: https://github.com/llvm/llvm-project/pull/120810.diff 1 Files Affected:
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
##----------------------------------------------------------------------------##
|
@llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) ChangesThis fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error. Full diff: https://github.com/llvm/llvm-project/pull/120810.diff 1 Files Affected:
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
##----------------------------------------------------------------------------##
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a minor comment about a possibly unnecessary variable. Otherwise, LGTM.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/11930 Here is the relevant piece of the build log for the reference
|
…lvm#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]>
…lvm#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]>
This fixes a bug where report links generated from files such as StylePrimitiveNumericTypes+Conversions.h in WebKit result in an error.