8176453: Javadoc search: there are issues with generics in parameters
Reviewed-by: jjg, sundar
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Fri Aug 31 11:43:06 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Fri Aug 31 12:41:00 2018 +0200
@@ -32,11 +32,16 @@
var highlight = "<span class=\"resultHighlight\">$&</span>";
var camelCaseRegexp = "";
var secondaryMatcher = "";
+function escapeHtml(str) {
+ return str.replace(/</g, "<").replace(/>/g, ">");
+}
function getHighlightedText(item) {
- var ccMatcher = new RegExp(camelCaseRegexp);
- var label = item.replace(ccMatcher, highlight);
- if (label === item) {
- label = item.replace(secondaryMatcher, highlight);
+ var ccMatcher = new RegExp(escapeHtml(camelCaseRegexp));
+ var escapedItem = escapeHtml(item);
+ var label = escapedItem.replace(ccMatcher, highlight);
+ if (label === escapedItem) {
+ var secMatcher = new RegExp(escapeHtml(secondaryMatcher.source), "i");
+ label = escapedItem.replace(secMatcher, highlight);
}
return label;
}