Bug 552946 - < and > characters are not escaped in Annotation values displayed in Javadoc
Summary: < and > characters are not escaped in Annotation values displayed in Javadoc
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2019-11-12 05:39 EST by Bence Sipka CLA
Modified: 2022-05-30 09:51 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bence Sipka CLA 2019-11-12 05:39:20 EST
Given the following code snippet:

	package mypackage;

	@MyAnnot(format = "<first-component><second-component>[<optional>]")
	public class MyClass {

	}

	@interface MyAnnot {
		public String format();
	}

The Javadoc view shows the following contents:

	mypackage.MyClass

	@MyAnnot(format="[]")

Instead of 

	mypackage.MyClass

	@MyAnnot(format="<first-component><second-component>[<optional>]")

The contents inside < and > are interpreted as HTML elements and not displayed.

Putting <a></a> and other elements inside the string contents of an annotation value will result in them being displayed as the corresponding HTML elements.
Comment 1 Stephan Herrmann CLA 2019-11-21 10:15:33 EST
I found an interesting comment in org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.addValue(StringBuffer, Object, boolean):

// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags in String-valued annotations.

This was added during bug 357325, which, however, doesn't add more explanation.

When testing with javadoc versions I found 1.7 to indeed have the bug, but in 1.8 this is fixed.

Remains the question: is anybody interested in maintaining bug-compatibility at 1.7 and below?
Comment 2 Noopur Gupta CLA 2020-01-02 04:22:49 EST
(In reply to Stephan Herrmann from comment #1)
> Remains the question: is anybody interested in maintaining bug-compatibility
> at 1.7 and below?
No. We should escape the HTML tags now.
Comment 3 Eclipse Genie CLA 2022-05-30 09:51:48 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.