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