--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Mon Mar 26 17:30:14 2018 -0700
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Mon Mar 26 18:07:24 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,41 +33,6 @@
var highlight = "<span class=\"resultHighlight\">$&</span>";
var camelCaseRegexp = "";
var secondaryMatcher = "";
-function getName(name) {
- var anchor = "";
- var ch = '';
- for (i = 0; i < name.length; i++) {
- ch = name.charAt(i);
- switch (ch) {
- case '(':
- case ')':
- case '<':
- case '>':
- case ',':
- anchor += "-";
- break;
- case ' ':
- case '[':
- break;
- case ']':
- anchor += ":A";
- break;
- case '$':
- if (i == 0)
- anchor += "Z:Z";
- anchor += ":D";
- break;
- case '_':
- if (i == 0)
- anchor += "Z:Z";
- anchor += ch;
- break;
- default:
- anchor += ch;
- }
- }
- return anchor;
-}
function getHighlightedText(item) {
var ccMatcher = new RegExp(camelCaseRegexp);
var label = item.replace(ccMatcher, highlight);
@@ -357,7 +322,7 @@
if (ui.item.url) {
url += ui.item.url;
} else {
- url += getName(ui.item.l);
+ url += ui.item.l;
}
} else if (ui.item.category === catSearchTags) {
url += ui.item.u;
--- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java Mon Mar 26 17:30:14 2018 -0700
+++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java Mon Mar 26 18:07:24 2018 -0700
@@ -24,7 +24,7 @@
/*
* @test
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
- * 8181622 8182263 8074407 8187521 8198522 8182765
+ * 8181622 8182263 8074407 8187521 8198522 8182765 8199278
* @summary Test the search feature of javadoc.
* @author bpatel
* @library ../lib
@@ -307,14 +307,44 @@
@Test
void testNoModuleDirectories() {
- javadoc("-d", "out-noMdlDir", "--no-module-directories", "-Xdoclint:none",
+ javadoc("-d", "out-noMdlDir",
+ "--no-module-directories",
+ "-Xdoclint:none",
"-sourcepath", testSrc,
- "-use", "pkg", "pkg1", "pkg2", "pkg3");
+ "-use",
+ "pkg", "pkg1", "pkg2", "pkg3");
checkExit(Exit.OK);
checkSearchOutput(true, false);
checkSearchJS();
}
+ @Test
+ void testURLEncoding() {
+ javadoc("-d", "out-encode-html5",
+ "--no-module-directories",
+ "-Xdoclint:none",
+ "-sourcepath", testSrc,
+ "-use",
+ "pkg", "pkg1", "pkg2", "pkg3");
+ checkExit(Exit.OK);
+ checkSearchJS();
+ checkSearchIndex(true);
+ }
+
+ @Test
+ void testURLEncoding_html4() {
+ javadoc("-d", "out-encode-html4",
+ "-html4",
+ "--no-module-directories",
+ "-Xdoclint:none",
+ "-sourcepath", testSrc,
+ "-use",
+ "pkg", "pkg1", "pkg2", "pkg3");
+ checkExit(Exit.OK);
+ checkSearchJS();
+ checkSearchIndex(false);
+ }
+
void checkDocLintErrors() {
checkOutput(Output.OUT, true,
"A sample method. Testing search tag for {@index \"unclosed quote}.",
@@ -327,6 +357,19 @@
checkSearchOutput("overview-summary.html", expectedOutput, true);
}
+ void checkSearchIndex(boolean expectedOutput) {
+ checkOutput("member-search-index.js", expectedOutput,
+ "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"AnotherClass()\",\"url\":\"%3Cinit%3E()\"}",
+ "{\"p\":\"pkg1\",\"c\":\"RegClass\",\"l\":\"RegClass()\",\"url\":\"%3Cinit%3E()\"}",
+ "{\"p\":\"pkg2\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"%3Cinit%3E()\"}",
+ "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method(byte[],int,java.lang.String)\"}");
+ checkOutput("member-search-index.js", !expectedOutput,
+ "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(RegClass)\",\"url\":\"method-pkg1.RegClass-\"}",
+ "{\"p\":\"pkg2\",\"c\":\"TestClass\",\"l\":\"TestClass()\",\"url\":\"TestClass--\"}",
+ "{\"p\":\"pkg\",\"c\":\"TestError\",\"l\":\"TestError()\",\"url\":\"TestError--\"}",
+ "{\"p\":\"pkg\",\"c\":\"AnotherClass\",\"l\":\"method(byte[], int, String)\",\"url\":\"method-byte:A-int-java.lang.String-\"}");
+ }
+
void checkSearchOutput(boolean expectedOutput, boolean moduleDirectoriesVar) {
checkSearchOutput("overview-summary.html", expectedOutput, moduleDirectoriesVar);
}
@@ -594,7 +637,8 @@
+ " }\n"
+ " }\n"
+ " return urlPrefix;\n"
- + "}");
+ + "}",
+ "url += ui.item.l;");
}
void checkSingleIndexSearchTagDuplication() {