Description
Javadoc inline tags {@literal} and {@code} with XML special characters (<, >) not handled correctly in metadata and xdoc generation .
There are two bugs:
-
{@literal} is not handled - JavadocMetadataScraperUtil.constructSubTreeText() and SiteUtil.getDescriptionFromJavadocForXdoc() have no logic for LITERAL_INLINE_TAG nodes. The child nodes (including syntax tokens {,@literal, }) are written to the output as plain text instead of being processed. This becomes a breaking issue when the content contains XML special characters like < or >, as they are not escaped.
-
{@code} does not escape < and > - adjustCodeInlineTagChildToHtml() only escapes & -> &, but not < -> < or > -> >. This means {@code <p>} produces <code><p></code> (broken XML) instead of the correct <code><p></code>.
How to Reproduce
Add {@literal <} or {@code <p>} to any module's class-level Javadoc and run mvn clean verify. The build will fail because the generated meta XML and/or xdoc XML files contain invalid XML.
For example, changing a module's Javadoc from:
Each paragraph but the first has <p> immediately
to the preferred inline tag form:
Each paragraph but the first has {@code <p>} immediately
causes the meta XML generator to produce <code><p></code> instead of <code><p></code>, resulting in malformed XML because the <p> is not escaped and gets interpreted as an actual HTML tag.
Actual Behavior
Currently, the generators produce broken output:
{@literal <} -> {@literal <} (raw structural tokens leak into the output as plain text)
{@literal >} -> {@literal >} (same issue)
{@code <p>} -> <code><p></code> (the <p> is not escaped, producing invalid XML)
{@code &} -> <code>&</code> (only & escaping works correctly)
Expected Behavior
After the fix, the generators should produce correct XML output:
{@literal <} -> < in both meta XML and xdoc output
{@literal >} -> > in both meta XML and xdoc output
{@code <p>} -> <code><p></code> in both meta XML and xdoc output
Description
Javadoc inline tags {@literal} and {@code} with XML special characters (
<,>) not handled correctly in metadata and xdoc generation .There are two bugs:
{@literal}is not handled -JavadocMetadataScraperUtil.constructSubTreeText()andSiteUtil.getDescriptionFromJavadocForXdoc()have no logic forLITERAL_INLINE_TAGnodes. The child nodes (including syntax tokens{,@literal,}) are written to the output as plain text instead of being processed. This becomes a breaking issue when the content contains XML special characters like<or>, as they are not escaped.{@code}does not escape<and>-adjustCodeInlineTagChildToHtml()only escapes&->&, but not<-><or>->>. This means{@code <p>}produces<code><p></code>(broken XML) instead of the correct<code><p></code>.How to Reproduce
Add
{@literal <}or{@code <p>}to any module's class-level Javadoc and runmvn clean verify. The build will fail because the generated meta XML and/or xdoc XML files contain invalid XML.For example, changing a module's Javadoc from:
Each paragraph but the first has <p> immediatelyto the preferred inline tag form:
Each paragraph but the first has {@code <p>} immediatelycauses the meta XML generator to produce
<code><p></code>instead of<code><p></code>, resulting in malformed XML because the<p>is not escaped and gets interpreted as an actual HTML tag.Actual Behavior
Currently, the generators produce broken output:
{@literal <}->{@literal <}(raw structural tokens leak into the output as plain text){@literal >}->{@literal >}(same issue){@code <p>}-><code><p></code>(the<p>is not escaped, producing invalid XML){@code &}-><code>&</code>(only&escaping works correctly)Expected Behavior
After the fix, the generators should produce correct XML output:
{@literal <}-><in both meta XML and xdoc output{@literal >}->>in both meta XML and xdoc output{@code <p>}-><code><p></code>in both meta XML and xdoc output