JDK-7011777 : JDK 6 parses html text with script tags within comments differently from previous releases
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u23
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux
  • CPU: x86
  • Submitted: 2011-01-12
  • Updated: 2015-04-21
  • Resolved: 2014-08-26
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 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
Parsing the following snippet with javax.swing.text.html.parser.ParserDelegator

<script>
<!--
function foo() {
  var tag1 = "</script>";
  var tag2 = "<div>";
  var tag3 = "</div>";
  var tag4 = "<script>";
}
// -->
</script>

JDK 6 will break at line 
  var tag1 = "</script>";

Previous jdk 1.4.2_x and 5.0_x, it will determine the comments correctly and break at
//-->

Comments
We have no plans to fix it
26-08-2014

SUGGESTED FIX Suggested fix is to add a check into parseScript() function which will determine if we're currently insude comment and disable a return from parseScript(). Pseudocode would look like this: boolean insideComment = false; if (inside comment) { insideComment = true; } else if (outside comment) { insideComment = false; } if (</script> tag encountered AND !insideComment) { return; }
20-06-2011

EVALUATION parseScript() function in Parser.java returns when </script> tag is encountered whithout any check if logically we're currently inside comment or string literal i.e. parser will break on these strings: <!-- </script> --> var x = "</script>" This function is absent prior to JDK6 so the provided testcase works fine with JDK4 and JDK5. However it's not possible to make Parser.java work as in JDK5 because large amount of changes was introduced to HTML parser with JDK6.
20-06-2011

EVALUATION This is a regression introduced by 6325159.
14-06-2011