提交 a1eaf82e 编写于 作者: M mcherkas

8078268: javax.swing.text.html.parser.Parser parseScript incorrectly optimized

Reviewed-by: alexp, aivanov
上级 85355489
......@@ -1986,57 +1986,69 @@ class Parser implements DTDConstants {
while (true) {
int i = 0;
while (!insideComment && i < SCRIPT_END_TAG.length
&& (SCRIPT_END_TAG[i] == ch
|| SCRIPT_END_TAG_UPPER_CASE[i] == ch)) {
&& (SCRIPT_END_TAG[i] == ch
|| SCRIPT_END_TAG_UPPER_CASE[i] == ch)) {
charsToAdd[i] = (char) ch;
ch = readCh();
i++;
}
if (i == SCRIPT_END_TAG.length) {
/* '</script>' tag detected */
/* Here, ch == the first character after </script> */
return;
} else {
/* To account for extra read()'s that happened */
for (int j = 0; j < i; j++) {
addString(charsToAdd[j]);
}
}
switch (ch) {
case -1:
error("eof.script");
return;
case '\n':
ln++;
if (!insideComment && i == 1 && charsToAdd[0] == START_COMMENT.charAt(0)) {
// it isn't end script tag, but may be it's start comment tag?
while (i < START_COMMENT.length()
&& START_COMMENT.charAt(i) == ch) {
charsToAdd[i] = (char) ch;
ch = readCh();
lfCount++;
addString('\n');
break;
case '\r':
ln++;
if ((ch = readCh()) == '\n') {
ch = readCh();
crlfCount++;
} else {
crCount++;
}
addString('\n');
break;
default:
addString(ch);
String str = new String(getChars(0, strpos));
if (!insideComment && str.endsWith(START_COMMENT)) {
insideComment = true;
}
if (insideComment && str.endsWith(END_COMMENT)) {
insideComment = false;
}
i++;
}
if (i == START_COMMENT.length()) {
insideComment = true;
}
}
if (insideComment) {
while (i < END_COMMENT.length()
&& END_COMMENT.charAt(i) == ch) {
charsToAdd[i] = (char) ch;
ch = readCh();
break;
} // switch
i++;
}
if (i == END_COMMENT.length()) {
insideComment = false;
}
}
/* To account for extra read()'s that happened */
for (int j = 0; j < i; j++) {
addString(charsToAdd[j]);
}
switch (ch) {
case -1:
error("eof.script");
return;
case '\n':
ln++;
ch = readCh();
lfCount++;
addString('\n');
break;
case '\r':
ln++;
if ((ch = readCh()) == '\n') {
ch = readCh();
crlfCount++;
} else {
crCount++;
}
addString('\n');
break;
default:
addString(ch);
ch = readCh();
break;
} // switch
} // while
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册