提交 a1eaf82e 编写于 作者: M mcherkas

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

Reviewed-by: alexp, aivanov
上级 85355489
...@@ -1993,17 +1993,37 @@ class Parser implements DTDConstants { ...@@ -1993,17 +1993,37 @@ class Parser implements DTDConstants {
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 { }
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();
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();
i++;
}
if (i == END_COMMENT.length()) {
insideComment = false;
}
}
/* To account for extra read()'s that happened */ /* To account for extra read()'s that happened */
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
addString(charsToAdd[j]); addString(charsToAdd[j]);
} }
switch (ch) { switch (ch) {
case -1: case -1:
error("eof.script"); error("eof.script");
...@@ -2026,17 +2046,9 @@ class Parser implements DTDConstants { ...@@ -2026,17 +2046,9 @@ class Parser implements DTDConstants {
break; break;
default: default:
addString(ch); 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; break;
} // switch } // switch
}
} // while } // while
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册