# HG changeset patch # User mcherkas # Date 1369092027 -14400 # Node ID ec24ad8455ec0500896c80368a47c5249fcb8988 # Parent 8020a243070425e7e12132cff9c739cb48b1d17f 7011777: JDK 6 parses html text with script tags within comments differently from previous releases Reviewed-by: alexsch Contributed-by: Dmitry Markov diff -r 8020a2430704 -r ec24ad8455ec jdk/src/share/classes/javax/swing/text/html/parser/Parser.java --- a/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java Fri May 17 14:11:06 2013 +0400 +++ b/jdk/src/share/classes/javax/swing/text/html/parser/Parser.java Tue May 21 03:20:27 2013 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1980,11 +1980,12 @@ void parseScript() throws IOException { char[] charsToAdd = new char[SCRIPT_END_TAG.length]; + boolean insideComment = false; /* Here, ch should be the first character after \";\n" + + " var tag2 = \"
\";\n" + + " var tag3 = \"
\";\n" + + " var tag4 = \""; + public static void main(String[] args) throws Exception { + new ParserDelegator().parse(new StringReader(html), new MyParserCallback(), true); + } + + static class MyParserCallback extends HTMLEditorKit.ParserCallback { + + @Override + public void handleComment(char[] data, int pos) { + String commentWithoutTags = comment.substring("".length()); + String str = new String(data); + if (!commentWithoutTags.equals(str)) { + System.out.println("Sample string:\n" + commentWithoutTags); + System.out.println("Returned string:\n" + str); + throw new RuntimeException("Test Failed, sample and returned strings are mismatched!"); + } + } + } + +}