### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java,v
retrieving revision 1.12
diff -u -r1.12 JavadocTagConstants.java
--- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java 23 May 2007 18:49:05 -0000 1.12
+++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java 11 Jul 2007 10:51:10 -0000
@@ -80,7 +80,9 @@
*/
public final static int BLOCK_IDX = 0;
public final static int INLINE_IDX = 1;
-
+
+ // href tag
+ public final static char[] HREF_TAG = {'h', 'r', 'e', 'f'};
/*
* Tags versions
*/
Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v
retrieving revision 1.67
diff -u -r1.67 AbstractCommentParser.java
--- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 27 Apr 2007 15:51:39 -0000 1.67
+++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 11 Jul 2007 10:51:10 -0000
@@ -89,6 +89,7 @@
protected Object[] astStack;
protected int astLengthPtr;
protected int[] astLengthStack;
+
protected AbstractCommentParser(Parser sourceParser) {
this.sourceParser = sourceParser;
@@ -529,32 +530,32 @@
if (readToken() == TerminalTokens.TokenNameIdentifier) {
consumeToken();
try {
- if (CharOperation.equals(this.scanner.getCurrentIdentifierSource(), new char[]{'h', 'r', 'e', 'f'}, false) &&
+ if (CharOperation.equals(this.scanner.getCurrentIdentifierSource(), HREF_TAG, false) &&
readToken() == TerminalTokens.TokenNameEQUAL) {
consumeToken();
if (readToken() == TerminalTokens.TokenNameStringLiteral) {
consumeToken();
- // Skip all characters after string literal until closing '>' (see bug 68726)
- while (readToken() != TerminalTokens.TokenNameGREATER) {
- if (this.scanner.currentPosition >= this.scanner.eofPosition || this.scanner.currentCharacter == '@' ||
- (this.inlineTagStarted && this.scanner.currentCharacter == '}')) {
- // Reset position: we want to rescan last token
- this.index = this.tokenPreviousPosition;
- this.scanner.currentPosition = this.tokenPreviousPosition;
- this.currentTokenType = -1;
- // Signal syntax error
- if (this.tagValue != TAG_VALUE_VALUE) { // do not report error for @value tag, this will be done after...
- if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(start, this.lineEnd);
+ while (this.index < this.javadocEnd) { // main loop to search for the pattern
+ // Skip all characters after string literal until closing '>' (see bug 68726)
+ while (readToken() != TerminalTokens.TokenNameGREATER) {
+ if (this.scanner.currentPosition >= this.scanner.eofPosition || this.scanner.currentCharacter == '@' ||
+ (this.inlineTagStarted && this.scanner.currentCharacter == '}')) {
+ // Reset position: we want to rescan last token
+ this.index = this.tokenPreviousPosition;
+ this.scanner.currentPosition = this.tokenPreviousPosition;
+ this.currentTokenType = -1;
+ // Signal syntax error
+ if (this.tagValue != TAG_VALUE_VALUE) { // do not report error for @value tag, this will be done after...
+ if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidSeeUrlReference(start, this.lineEnd);
+ }
+ return false;
}
- return false;
+ this.currentTokenType = -1; // consume token without updating line end
}
- this.currentTokenType = -1; // do not update line end
- }
- if (this.currentTokenType == TerminalTokens.TokenNameGREATER) {
consumeToken(); // update line end as new lines are allowed in URL description
while (readToken() != TerminalTokens.TokenNameLESS) {
if (this.scanner.currentPosition >= this.scanner.eofPosition || this.scanner.currentCharacter == '@' ||
- (this.inlineTagStarted && this.scanner.currentCharacter == '}')) {
+ (this.inlineTagStarted && this.scanner.currentCharacter == '}')) {
// Reset position: we want to rescan last token
this.index = this.tokenPreviousPosition;
this.scanner.currentPosition = this.tokenPreviousPosition;
@@ -569,15 +570,21 @@
}
consumeToken();
start = this.scanner.getCurrentTokenStartPosition();
- if (readChar() == '/') {
+ currentChar = readChar();
+ // search for the pattern and store last char read
+ if (currentChar == '/') {
currentChar = readChar();
- if (currentChar == 'a' || currentChar == 'A') {
- if (readChar() == '>') {
- // Valid href
- return true;
+ if (currentChar == 'a' || currentChar =='A') {
+ currentChar = readChar();
+ if (currentChar == '>') {
+ return true; // valid href
}
}
}
+ // search for invalid char in tags
+ if (currentChar == '\r' || currentChar == '\n' || currentChar == '\t' || currentChar == ' ') {
+ break;
+ }
}
}
}
#P org.eclipse.jdt.core.tests.compiler
Index: src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java,v
retrieving revision 1.36
diff -u -r1.36 JavadocBugsTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 16 Mar 2007 18:31:22 -0000 1.36
+++ src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java 11 Jul 2007 10:51:12 -0000
@@ -5773,4 +5773,122 @@
"Javadoc: Missing tag for parameter anotherInt\n" +
"----------\n");
}
+
+ /**
+ * @bug 125518: [javadoc] Embedding html in a link placed in a @see JavaDoc tag causes a warning
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125518"
+ */
+ public void testBug125518a() {
+ String[] units = new String[] {
+ "pkg/X.java",
+ "package pkg;\n" +
+ "\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see invalid>\n" +
+ " */\n" +
+ " public void foo() { \n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ };
+ reportInvalidJavadoc = CompilerOptions.WARNING;
+ runNegativeTest(units,
+ "----------\n" +
+ "1. WARNING in pkg\\X.java (at line 5)\n" +
+ " * @see invalid>\n" +
+ " ^^\n" +
+ "Javadoc: Malformed link reference\n" +
+ "----------\n");
+ }
+
+ public void testBug125518b() {
+ String[] units = new String[] {
+ "pkg/X.java",
+ "package pkg;\n" +
+ "\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see invalid>invalid>invalid>>\n" +
+ " */\n" +
+ " public void foo() { \n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ };
+ reportInvalidJavadoc = CompilerOptions.WARNING;
+ runNegativeTest(units,
+ "----------\n" +
+ "1. WARNING in pkg\\X.java (at line 5)\n" +
+ " * @see invalid>>\n" +
+ " ^^^\n" +
+ "Javadoc: Malformed link reference\n" +
+ "----------\n");
+ }
+
+ public void testBug125518d() {
+ String[] units = new String[] {
+ "pkg/X.java",
+ "package pkg;\n" +
+ "\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see invalid>\n" +
+ " */\n" +
+ " public void foo() { \n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ };
+ reportInvalidJavadoc = CompilerOptions.WARNING;
+ runNegativeTest(units,
+ "----------\n" +
+ "1. WARNING in pkg\\X.java (at line 5)\n" +
+ " * @see invalid>\n" +
+ " ^^^^^\n" +
+ "Javadoc: Malformed link reference\n" +
+ "----------\n");
+ }
+
+ public void testBug125518e() {
+ String[] units = new String[] {
+ "pkg/X.java",
+ "package pkg;\n" +
+ "\n" +
+ "public class X {\n" +
+ " /**\n" +
+ " * @see value\n" +
+ " */\n" +
+ " public void foo() { \n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ };
+ reportInvalidJavadoc = CompilerOptions.WARNING;
+ runConformTest(units);
+ }
}