Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251357: [DocCommentParser] Infinite loop while looking for the end o…
…f a preamble

Reviewed-by: jjg
  • Loading branch information
pavelrappo committed Aug 19, 2020
1 parent 8eed9aa commit 1da978d352c335af3d3e991f11b913deb3b7c0e3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
@@ -708,14 +708,14 @@ boolean isEndPreamble() {
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..."
@@ -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.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;
@@ -0,0 +1,5 @@
<!-- /nodynamiccopyright/ -->
<HTML>
<HEAD>
</HEAD>
<BODY lang="en"
@@ -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
@@ -0,0 +1,5 @@
<!-- /nodynamiccopyright/ -->
<HTML>
<HEAD>
</HEAD>
<BODY lang="en">
@@ -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

0 comments on commit 1da978d

Please sign in to comment.