RFR: 8351332: Line breaks in search tag descriptions corrupt JSON search index

Chen Liang liach at openjdk.org
Mon Mar 24 16:42:14 UTC 2025


On Mon, 24 Mar 2025 16:14:54 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexItem.java line 645:
>> 
>>> 643:                 if (!description.isEmpty()) {
>>> 644:                     String normalizedDescription = description.replaceAll("\\s+", " ");
>>> 645:                     builder.append("d", escapeQuotes(normalizedDescription));
>> 
>> Should we just handle all whitespaces in `escapeQuotes`?
>
> I thought about it but that may not be necessary because the other json keys (`l`, `h`, `u`) cannot have whitespace in them.
> 
> I'm not opposed to handing whitespace in an `escapeQuotesAndWhitespace` method though.

I think we should have one that escapes spaces and another that fails on spaces to replace the current escapeQuotes.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24202#discussion_r2010551795


More information about the javadoc-dev mailing list