jdk/src/share/classes/javax/swing/text/html/parser/Parser.java
changeset 17678 ec24ad8455ec
parent 14309 425e2c6b5941
child 20169 d7fa6d7586c9
equal deleted inserted replaced
17418:8020a2430704 17678:ec24ad8455ec
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1978     private static final char[] SCRIPT_END_TAG_UPPER_CASE =
  1978     private static final char[] SCRIPT_END_TAG_UPPER_CASE =
  1979                                         "</SCRIPT>".toCharArray();
  1979                                         "</SCRIPT>".toCharArray();
  1980 
  1980 
  1981     void parseScript() throws IOException {
  1981     void parseScript() throws IOException {
  1982         char[] charsToAdd = new char[SCRIPT_END_TAG.length];
  1982         char[] charsToAdd = new char[SCRIPT_END_TAG.length];
       
  1983         boolean insideComment = false;
  1983 
  1984 
  1984         /* Here, ch should be the first character after <script> */
  1985         /* Here, ch should be the first character after <script> */
  1985         while (true) {
  1986         while (true) {
  1986             int i = 0;
  1987             int i = 0;
  1987             while (i < SCRIPT_END_TAG.length
  1988             while (!insideComment && i < SCRIPT_END_TAG.length
  1988                        && (SCRIPT_END_TAG[i] == ch
  1989                        && (SCRIPT_END_TAG[i] == ch
  1989                            || SCRIPT_END_TAG_UPPER_CASE[i] == ch)) {
  1990                            || SCRIPT_END_TAG_UPPER_CASE[i] == ch)) {
  1990                 charsToAdd[i] = (char) ch;
  1991                 charsToAdd[i] = (char) ch;
  1991                 ch = readCh();
  1992                 ch = readCh();
  1992                 i++;
  1993                 i++;
  2023                     }
  2024                     }
  2024                     addString('\n');
  2025                     addString('\n');
  2025                     break;
  2026                     break;
  2026                 default:
  2027                 default:
  2027                     addString(ch);
  2028                     addString(ch);
       
  2029                     String str = new String(getChars(0, strpos));
       
  2030                     if (!insideComment && str.endsWith(START_COMMENT)) {
       
  2031                         insideComment = true;
       
  2032                     }
       
  2033                     if (insideComment && str.endsWith(END_COMMENT)) {
       
  2034                         insideComment = false;
       
  2035                     }
  2028                     ch = readCh();
  2036                     ch = readCh();
  2029                     break;
  2037                     break;
  2030                 } // switch
  2038                 } // switch
  2031             }
  2039             }
  2032         } // while
  2040         } // while