changeset 51607:5eb48e9d607a

8176453: Javadoc search: there are issues with generics in parameters Reviewed-by: jjg, sundar
author hannesw
date Fri, 31 Aug 2018 12:41:00 +0200
parents 18afb2097ada
children 625a5bdde0c5
files src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }