JDK-8177450 : javax.swing.text.html.parser.Parser parseScript ignores a character after comment end
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u112,9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2017-03-22
  • Updated: 2017-11-29
  • Resolved: 2017-04-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 JDK 9
10Fixed 8u152Fixed 9 b166Fixed
# java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

When html that containes script fileld like below is parsed, eof.script error is throwen.
     <script type="text/javascript"><!--
             function a(a) {}

It works fine when written as below:


It seems that because first character after END_COMMENT("-->") is ignored,
so parseScript() can't find SCRIPT_END_TAG("</script>").

It looks like a side effect of JDK-8078268 fix introduced in 8u112.
When run in 8u111, either pattern works fine.

REGRESSION.  Last worked in version 8u111

# ./jdk1.8.0_111/bin/java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

This bug can be reproduced always.

Updated: http://cr.openjdk.java.net/~mcherkas/8177450/9/webrev.02 Pending fix yes label

Fix Request : it's regression introduced by JDK-8078268. if we don't fix it, the html parser may work incorrent in some cases. The problem is that Parser reads extra symbol after comment or script tag and missed the symbol. I added 'continue' after those tags, so it goes to beginning of Parser while loop and process the symbol. Webrev: http://cr.openjdk.java.net/~mcherkas/8177450/9/webrev/ The fix is reviewed by [~alexsch]

Webrev: http://cr.openjdk.java.net/~mcherkas/8177450/9/webrev/

Review: http://mail.openjdk.java.net/pipermail/swing-dev/2017-March/007264.html

Checked this for 8u111, 8u112, 8u121 and 9 ea and could confirm the issue as reported. html that contains script reference as //--></script> when parsed, threw eof.script error with JDK version 8u112 and above including 9 ea. This works fine with space and CR. ======================== <script type="text/javascript"><!-- function a(a) {} //--></script> ======================== To reproduce run the attached test customized test case (ref. JDK-8028616) using following patterns as detailed in description: HTML test pattern: Pattern #1 //--></script> Pattern #2 //--> </script> # with space Pattern #3 //--> # with CR </script> Note: Edit test.html comment part(//--></script>) as required Result: ======== JDK version Pattern #1 Pattern #2 Pattern #3 8u111 b14 Pass Pass Pass 8u112 b15 Fail Pass Pass 8u121 b13 Fail Pass Pass 9ea b161 Fail Pass Pass This seems a regression in 8u112 likely originated from fix introduced with JDK-8078268.