neeraj      2002/12/12 02:42:37

  Modified:    java/src/org/apache/xerces/impl Tag: jaxp_1_2_2_branch
                        XMLEntityManager.java Constants.java
               java/src/org/apache/xerces/impl/msg Tag: jaxp_1_2_2_branch
                        XMLMessages.properties
  Log:
  
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.53.2.1  +41 -4     xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
  
  Index: XMLEntityManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
  retrieving revision 1.53
  retrieving revision 1.53.2.1
  diff -u -r1.53 -r1.53.2.1
  --- XMLEntityManager.java     21 Nov 2002 23:04:51 -0000      1.53
  +++ XMLEntityManager.java     12 Dec 2002 10:42:36 -0000      1.53.2.1
  @@ -180,6 +180,11 @@
       protected static final String BUFFER_SIZE =
           Constants.XERCES_PROPERTY_PREFIX + Constants.BUFFER_SIZE_PROPERTY;
   
  +    /** property identifier: Entity expansion limit */
  +    protected static final String ENTITY_EXPANSION_LIMIT  =
  +        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_EXPANSION_LIMIT;
  +
  +
       // recognized features and properties
   
       /** Recognized features. */
  @@ -206,7 +211,8 @@
           ERROR_REPORTER,
           ENTITY_RESOLVER,
           VALIDATION_MANAGER,
  -        BUFFER_SIZE
  +        BUFFER_SIZE,
  +        ENTITY_EXPANSION_LIMIT
       };
   
       /** Property defaults. */
  @@ -216,6 +222,7 @@
           null,
           null,
           new Integer(DEFAULT_BUFFER_SIZE),
  +        null
       };
   
       private static final String XMLEntity = "[xml]".intern();
  @@ -242,6 +249,7 @@
       //
       // Data
       //
  +    private static int entityExpansionLimit = 0 ;
   
       // features
   
  @@ -309,6 +317,10 @@
        */
       protected int fBufferSize = DEFAULT_BUFFER_SIZE;
   
  +    //Application can set the limit of number of entities that can be expanded.
  +    protected java.lang.Integer fEntityExpansionLimit = null ;
  +    protected  int fEntityExpansionCount ;
  +
       /**
        * True if the document entity is standalone. This should really
        * only be set by the document source (e.g. XMLDocumentScanner).
  @@ -837,7 +849,17 @@
                               boolean literal, boolean isExternal)
           throws IOException, XNIException {
           // get information
  -
  +        
  +        //when entity expansion limit is set by the Application, before opening any 
new entity
  +        //parser check for the entity expansion limit set by the parser, if number 
of entity
  +        //expansions exceeds the entity expansion limit, parser will throw fatal 
error.
  +        if( fEntityExpansionLimit != null && fEntityExpansionCount++ > 
fEntityExpansionLimit.intValue() ){
  +            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                             "EntityExpansionLimitExceeded",
  +                                             new Object[]{fEntityExpansionLimit },
  +                                             XMLErrorReporter.SEVERITY_FATAL_ERROR 
);
  +        }
  +        
           final String publicId = xmlInputSource.getPublicId();
           final String literalSystemId = xmlInputSource.getSystemId();
           String baseSystemId = xmlInputSource.getBaseSystemId();
  @@ -922,7 +944,7 @@
           // we've seen a new Reader. put it in a list, so that
           // we can close it later.
           fOwnReaders.addElement(reader);
  -
  +        
           // push entity on stack
           if (fCurrentEntity != null) {
               fEntityStack.push(fCurrentEntity);
  @@ -1036,6 +1058,15 @@
           catch (XMLConfigurationException e) {
               fValidationManager = null;
           }
  +        // adding new property 
http://xml.apache.org/properties/entity-expansion-limit
  +        // using this property application can set the limit of number of the 
entities that 
  +        // will be expanded.
  +        try {
  +            fEntityExpansionLimit = 
(java.lang.Integer)componentManager.getProperty(ENTITY_EXPANSION_LIMIT);
  +        }
  +        catch (XMLConfigurationException e) {
  +            fEntityExpansionLimit = null;
  +        }
           
           // initialize state
           fStandalone = false;
  @@ -1159,7 +1190,13 @@
                       bufferSize.intValue() > DEFAULT_XMLDECL_BUFFER_SIZE) {
                       fBufferSize = bufferSize.intValue();
                   }
  +                return ;
  +            }
  +            if (property.equals(Constants.ENTITY_EXPANSION_LIMIT)) {
  +                Integer entityExpansionLimit = (Integer)value;
  +                return ;
               }
  +            
           }
   
       } // setProperty(String,Object)
  
  
  
  1.24.2.1  +4 -1      xml-xerces/java/src/org/apache/xerces/impl/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
  retrieving revision 1.24
  retrieving revision 1.24.2.1
  diff -u -r1.24 -r1.24.2.1
  --- Constants.java    2 Dec 2002 19:28:45 -0000       1.24
  +++ Constants.java    12 Dec 2002 10:42:36 -0000      1.24.2.1
  @@ -273,6 +273,9 @@
       /** Input buffer size property ("input-buffer-size"). */
       public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
   
  +    /** ENTITY EXPANSION LIMIT */
  +    public static final String ENTITY_EXPANSION_LIMIT = "entity-expansion-limit";
  +    
       /** Entity resolver property ("internal/entity-resolver"). */
       public static final String ENTITY_RESOLVER_PROPERTY = 
"internal/entity-resolver";
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.1  +3 -0      
xml-xerces/java/src/org/apache/xerces/impl/msg/XMLMessages.properties
  
  Index: XMLMessages.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XMLMessages.properties,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- XMLMessages.properties    2 Dec 2002 19:26:53 -0000       1.15
  +++ XMLMessages.properties    12 Dec 2002 10:42:37 -0000      1.15.2.1
  @@ -274,3 +274,6 @@
           
MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID=MSG_SPACE_REQUIRED_AFTER_SYSTEMLITERAL_IN_EXTERNALID
           OpenQuoteMissingInDecl=OpenQuoteMissingInDecl
           InvalidCharInLiteral=InvalidCharInLiteral
  +
  +#Application can set the limit of number of entities that should be expanded by the 
parser.
  +EntityExpansionLimitExceeded=Parser has exceeded the entity expansion limit \"{0}\" 
set by the application.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to