8176453: Javadoc search: there are issues with generics in parameters
authorhannesw
Fri, 31 Aug 2018 12:41:00 +0200
changeset 51607 5eb48e9d607a
parent 51606 18afb2097ada
child 51608 625a5bdde0c5
8176453: Javadoc search: there are issues with generics in parameters Reviewed-by: jjg, sundar
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js
--- 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, "&lt;").replace(/>/g, "&gt;");
+}
 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;
 }