8251357: [DocCommentParser] Infinite loop while looking for the end of a preamble

Reviewed-by: jjg
This commit is contained in:
Pavel Rappo 2020-08-19 17:44:14 +01:00
parent 3fb8f4364d
commit ecfb2914d0
6 changed files with 65 additions and 5 deletions

View File

@ -708,14 +708,14 @@ public class DocCommentParser {
case "body":
// Check if also followed by <main>
// 1. skip rest of <body>
while (ch != -1 && ch != '>') {
while (bp < buflen && ch != '>') {
nextChar();
}
if (ch == '>') {
nextChar();
}
// 2. skip any whitespace
while (ch != -1 && Character.isWhitespace(ch)) {
while (bp < buflen && isWhitespace(ch)) {
nextChar();
}
// 3. check if looking at "<main..."

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/*
* @test
* @bug 8132096 8157611 8190552
* @bug 8132096 8157611 8190552 8251357
* @summary test the APIs in the DocTree interface
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.file
@ -53,7 +53,6 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.util.Elements;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
import javax.tools.StandardJavaFileManager;
import com.sun.source.doctree.DocTree;

View File

@ -0,0 +1,5 @@
<!-- /nodynamiccopyright/ -->
<HTML>
<HEAD>
</HEAD>
<BODY lang="en"

View File

@ -0,0 +1,23 @@
EXPECT_START
DocComment[DOC_COMMENT, pos:0
preamble: 5
Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
StartElement[START_ELEMENT, pos:30
name:HTML
attributes: empty
]
StartElement[START_ELEMENT, pos:37
name:HEAD
attributes: empty
]
EndElement[END_ELEMENT, pos:44, HEAD]
Erroneous[ERRONEOUS, pos:52
code: compiler.err.dc.malformed.html
body: <
]
firstSentence: 1
Text[TEXT, pos:53, BODY_lang="en"]
body: empty
block tags: empty
]
EXPECT_END

View File

@ -0,0 +1,5 @@
<!-- /nodynamiccopyright/ -->
<HTML>
<HEAD>
</HEAD>
<BODY lang="en">

View File

@ -0,0 +1,28 @@
EXPECT_START
DocComment[DOC_COMMENT, pos:0
preamble: 5
Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
StartElement[START_ELEMENT, pos:30
name:HTML
attributes: empty
]
StartElement[START_ELEMENT, pos:37
name:HEAD
attributes: empty
]
EndElement[END_ELEMENT, pos:44, HEAD]
StartElement[START_ELEMENT, pos:52
name:BODY
attributes: 1
Attribute[ATTRIBUTE, pos:58
name: lang
vkind: DOUBLE
value: 1
Text[TEXT, pos:64, en]
]
]
firstSentence: empty
body: empty
block tags: empty
]
EXPECT_END