RFR: JDK-8305710: Line breaks in search tags cause invalid JSON in index file

Hannes Wallnöfer hannesw at openjdk.org
Tue May 16 15:11:46 UTC 2023


This fixes a number of issues that can or could result in invalid JavaScript search index files, and a single invalid index file breaking the whole JavaDoc search feature.

 - The `IndexItem` now throws `IllegalArgumentException` if the label argument contains a line break. This was the original cause for this bug and was already fixed in [JDK-8305407](https://bugs.openjdk.org/browse/JDK-8305407), but it is a good idea to add the explicit check to fail in a visible way should it occur again.
 - The `IndexItem.escapeQuotes(String)` method now escapes backslashes in addition to quote. Failure to escape a trailing backslash would result in an escaped quote, leading to an invalid index file.
 - The search script gets a check for null/undefined to avoid a missing tag index file to break the search feature as a whole. 

Note that the added test covers only the second item in the list above. The other two changes are trivial and would require undue effort to test.

-------------

Commit messages:
 - JDK-8305710: Line breaks in search tags cause invalid JSON in index file

Changes: https://git.openjdk.org/jdk/pull/14016/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14016&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8305710
  Stats: 75 lines in 4 files changed: 45 ins; 6 del; 24 mod
  Patch: https://git.openjdk.org/jdk/pull/14016.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14016/head:pull/14016

PR: https://git.openjdk.org/jdk/pull/14016


More information about the javadoc-dev mailing list