New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javadoc parser: custom tags content should not be parsed as HTML #4164

Closed
romani opened this Issue Apr 5, 2017 · 1 comment

Comments

@romani
Member

romani commented Apr 5, 2017

Parser error on javadoc content of custom tag with < (html symbol)
Non standard {@preformat a<b} parsed with error.

$ cat Test.java 
/**
 * standard inline tag: {@code a < b} , parsed ok.
 * standard inline tag: {@code a<b} , parsed ok.
 * Non standard {@preformat a < b} parsed ok.
 */
public class Test {
}

$ java -jar checkstyle-7.6-all.jar -J Test.java
CLASS_DEF -> CLASS_DEF [6:0]
|--MODIFIERS -> MODIFIERS [6:0]
|   |--BLOCK_COMMENT_BEGIN -> /* [1:0]
|   |   |--COMMENT_CONTENT -> *\n * standard inline tag: {@code a < b} , parsed ok.\n * standard inline tag: {@code a<b} , parsed ok.\n * Non standard {@preformat a < b} parsed ok.\n  [1:2]
|   |   |   `--JAVADOC -> \n * standard inline tag: {@code a < b} , parsed ok.\n * standard inline tag: {@code a<b} , parsed ok.\n * Non standard {@preformat a < b} parsed ok.\n <EOF> [1:3]
|   |   |       |--NEWLINE -> \n [1:3]
|   |   |       |--LEADING_ASTERISK ->  * [2:0]
|   |   |       |--TEXT ->  standard inline tag:  [2:2]
|   |   |       |--JAVADOC_INLINE_TAG -> {@code a < b} [2:24]
|   |   |       |   |--JAVADOC_INLINE_TAG_START -> { [2:24]
|   |   |       |   |--CODE_LITERAL -> @code [2:25]
|   |   |       |   |--WS ->   [2:30]
|   |   |       |   |--TEXT -> a < b [2:31]
|   |   |       |   `--JAVADOC_INLINE_TAG_END -> } [2:37]
|   |   |       |--TEXT ->  , parsed ok. [2:38]
|   |   |       |--NEWLINE -> \n [2:51]
|   |   |       |--LEADING_ASTERISK ->  * [3:0]
|   |   |       |--TEXT ->  standard inline tag:  [3:2]
|   |   |       |--JAVADOC_INLINE_TAG -> {@code a<b} [3:24]
|   |   |       |   |--JAVADOC_INLINE_TAG_START -> { [3:24]
|   |   |       |   |--CODE_LITERAL -> @code [3:25]
|   |   |       |   |--WS ->   [3:30]
|   |   |       |   |--TEXT -> a<b [3:31]
|   |   |       |   `--JAVADOC_INLINE_TAG_END -> } [3:35]
|   |   |       |--TEXT ->  , parsed ok. [3:36]
|   |   |       |--NEWLINE -> \n [3:49]
|   |   |       |--LEADING_ASTERISK ->  * [4:0]
|   |   |       |--TEXT ->  Non standard  [4:2]
|   |   |       |--JAVADOC_INLINE_TAG -> {@preformat a < b} [4:16]
|   |   |       |   |--JAVADOC_INLINE_TAG_START -> { [4:16]
|   |   |       |   |--CUSTOM_NAME -> @preformat [4:17]
|   |   |       |   |--WS ->   [4:27]
|   |   |       |   |--DESCRIPTION -> a < b [4:28]
|   |   |       |   |   `--TEXT -> a < b [4:28]
|   |   |       |   `--JAVADOC_INLINE_TAG_END -> } [4:33]
|   |   |       |--TEXT ->  parsed ok. [4:34]
|   |   |       |--NEWLINE -> \n [4:45]
|   |   |       |--TEXT ->   [5:0]
|   |   |       `--EOF -> <EOF> [5:1]
|   |   `--BLOCK_COMMENT_END -> */ [5:1]
|   `--LITERAL_PUBLIC -> public [6:0]
|--LITERAL_CLASS -> class [6:7]
|--IDENT -> Test [6:13]
`--OBJBLOCK -> OBJBLOCK [6:18]
    |--LCURLY -> { [6:18]
    `--RCURLY -> } [7:0]

$ cat Test.java 
/**
 * standard inline tag: {@code a < b} , parsed ok.
 * standard inline tag: {@code a<b} , parsed ok.
 * Non standard {@preformat a < b} parsed ok.
 * Non standard {@preformat a<b} parsed with error.
 */
public class Test {
}

$ java -jar checkstyle-7.6-all.jar -J Test.java
Exception in thread "main" java.lang.IllegalArgumentException: [ERROR:5] Javadoc comment at column 32 has parse error. Details: no viable alternative at input '<b}' while parsing HTML_ELEMENT
	at com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter.parseJavadocAsDetailNode(DetailNodeTreeStringPrinter.java:71)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.parseAndPrintJavadocTree(AstTreeStringPrinter.java:117)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printJavaAndJavadocTree(AstTreeStringPrinter.java:99)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printJavaAndJavadocTree(AstTreeStringPrinter.java:103)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printJavaAndJavadocTree(AstTreeStringPrinter.java:103)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printJavaAndJavadocTree(AstTreeStringPrinter.java:103)
	at com.puppycrawl.tools.checkstyle.AstTreeStringPrinter.printJavaAndJavadocTree(AstTreeStringPrinter.java:82)
	at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:333)
	at com.puppycrawl.tools.checkstyle.Main.main(Main.java:174)

Expected: parsing without error.

@Vladlis Vladlis added the GSoC2017 label May 10, 2017

@Vladlis Vladlis assigned Vladlis and unassigned Vladlis May 10, 2017

@Vladlis Vladlis added GSoC2017 and removed GSoC2017 labels May 10, 2017

@Vladlis Vladlis assigned ps-sp and unassigned ps-sp May 22, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 27, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 27, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 27, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 27, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 27, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 28, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue May 28, 2017

@Vladlis Vladlis moved this from To Do to In Progress in Javadoc style coverage and parser optimization May 28, 2017

@Vladlis Vladlis moved this from In Progress to Review in Javadoc style coverage and parser optimization May 28, 2017

ps-sp added a commit to ps-sp/checkstyle that referenced this issue Jun 8, 2017

romani added a commit that referenced this issue Jun 19, 2017

@romani romani added the bug label Jun 19, 2017

@romani romani added this to the 8.0 milestone Jun 19, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 19, 2017

Member

fix is merged

Member

romani commented Jun 19, 2017

fix is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment