jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java
changeset 37626 d4fb6a5dc001
parent 36146 eca249f3c768
child 39798 550955727ef7
equal deleted inserted replaced
37396:8d78fb40648d 37626:d4fb6a5dc001
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     3  */
     3  */
     4 
     4 
     5 /*
     5 /*
     6  * Copyright 2005 The Apache Software Foundation.
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
       
     7  * contributor license agreements.  See the NOTICE file distributed with
       
     8  * this work for additional information regarding copyright ownership.
       
     9  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    10  * (the "License"); you may not use this file except in compliance with
       
    11  * the License.  You may obtain a copy of the License at
     7  *
    12  *
     8  * Licensed under the Apache License, Version 2.0 (the "License");
    13  *     http://www.apache.org/licenses/LICENSE-2.0
     9  * you may not use this file except in compliance with the License.
       
    10  * You may obtain a copy of the License at
       
    11  *
       
    12  *      http://www.apache.org/licenses/LICENSE-2.0
       
    13  *
    14  *
    14  * Unless required by applicable law or agreed to in writing, software
    15  * Unless required by applicable law or agreed to in writing, software
    15  * distributed under the License is distributed on an "AS IS" BASIS,
    16  * distributed under the License is distributed on an "AS IS" BASIS,
    16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    17  * See the License for the specific language governing permissions and
    18  * See the License for the specific language governing permissions and
    18  * limitations under the License.
    19  * limitations under the License.
    19  */
    20  */
    20 
    21 
    21 package com.sun.org.apache.xerces.internal.impl;
    22 package com.sun.org.apache.xerces.internal.impl;
    22 import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
    23 
    23 import java.io.EOFException;
    24 import com.sun.org.apache.xerces.internal.impl.Constants;
    24 import java.io.IOException;
       
    25 
       
    26 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
    25 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
    27 
    26 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
       
    27 import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
    28 import com.sun.org.apache.xerces.internal.util.SymbolTable;
    28 import com.sun.org.apache.xerces.internal.util.SymbolTable;
    29 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
    29 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
    30 import com.sun.org.apache.xerces.internal.util.XMLChar;
    30 import com.sun.org.apache.xerces.internal.util.XMLChar;
    31 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
    31 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
    32 
    32 import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
       
    33 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
    33 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
    34 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
    34 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
    35 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
    35 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
    36 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
    36 import com.sun.org.apache.xerces.internal.xni.XMLString;
    37 import com.sun.org.apache.xerces.internal.xni.XMLString;
    37 import com.sun.org.apache.xerces.internal.xni.XNIException;
    38 import com.sun.org.apache.xerces.internal.xni.XNIException;
    39 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
    40 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
    40 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
    41 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
    41 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
    42 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
    42 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    43 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
    43 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    44 import com.sun.org.apache.xerces.internal.xni.Augmentations;
    44 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
    45 import com.sun.xml.internal.stream.dtd.nonvalidating.DTDGrammar;
    45 import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
    46 import java.io.EOFException;
    46 import com.sun.org.apache.xerces.internal.impl.Constants;
    47 import java.io.IOException;
    47 import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
       
    48 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
       
    49 
    48 
    50 /**
    49 /**
    51  * This class is responsible for scanning the declarations found
    50  * This class is responsible for scanning the declarations found
    52  * in the internal and external subsets of a DTD in an XML document.
    51  * in the internal and external subsets of a DTD in an XML document.
    53  * The scanner acts as the sources for the DTD information which is
    52  * The scanner acts as the sources for the DTD information which is
   385      * @return true if DTD is skipped, false otherwise.
   384      * @return true if DTD is skipped, false otherwise.
   386      * @throws java.io.IOException if i/o error occurs
   385      * @throws java.io.IOException if i/o error occurs
   387      */
   386      */
   388     @Override
   387     @Override
   389     public boolean skipDTD(boolean supportDTD) throws IOException {
   388     public boolean skipDTD(boolean supportDTD) throws IOException {
   390         if (!supportDTD) {
   389         if (supportDTD)
   391             fStringBuffer.clear();
   390             return false;
   392             if (!fEntityScanner.scanData("]", fStringBuffer)) {
   391 
   393                 fEntityScanner.fCurrentEntity.position--;
   392         fStringBuffer.clear();
   394             }
   393         while (fEntityScanner.scanData("]", fStringBuffer)) {
   395 
   394             int c = fEntityScanner.peekChar();
   396             return true;
   395             if (c != -1) {
   397         }
   396                 if (XMLChar.isHighSurrogate(c)) {
   398         return false;
   397                     scanSurrogates(fStringBuffer);
       
   398                 }
       
   399                 if (isInvalidLiteral(c)) {
       
   400                     reportFatalError("InvalidCharInDTD",
       
   401                         new Object[] { Integer.toHexString(c) });
       
   402                     fEntityScanner.scanChar();
       
   403                 }
       
   404             }
       
   405         }
       
   406         fEntityScanner.fCurrentEntity.position--;
       
   407         return true;
   399     }
   408     }
   400 
   409 
   401     //
   410     //
   402     // XMLComponent methods
   411     // XMLComponent methods
   403     //
   412     //