neeraj 2004/01/27 00:00:02 Modified: java/src/org/apache/xerces/impl Tag: jaxp_1_2_3_branch XMLDocumentFragmentScannerImpl.java java/src/org/apache/xerces/impl/msg Tag: jaxp_1_2_3_branch XMLMessages.properties Log: Revision Changes Path No revision No revision 1.26.2.1 +27 -2 xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java Index: XMLDocumentFragmentScannerImpl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -r1.26 -r1.26.2.1 --- XMLDocumentFragmentScannerImpl.java 7 Dec 2002 00:15:58 -0000 1.26 +++ XMLDocumentFragmentScannerImpl.java 27 Jan 2004 08:00:01 -0000 1.26.2.1 @@ -164,6 +164,10 @@ protected static final String NOTIFY_BUILTIN_REFS = Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_BUILTIN_REFS_FEATURE; + + protected static final String SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ; + protected static final int DEFAULT_ELEMENT_ATTRIBUTE_LIMIT = 10000; + // recognized features and properties /** Recognized features. */ @@ -234,6 +238,9 @@ /** Standalone. */ protected boolean fStandalone; + //variable to restrict attribute limit + protected int fElementAttributeLimit; + // element information /** Current element. */ @@ -405,6 +412,19 @@ fHasExternalDTD = false; fStandalone = false; + + //There is little overhead in doing this again and again but it allows to reset the value b/w parse + try{ + String value = System.getProperty(SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT); + if(value != null && !value.equals("")) + fElementAttributeLimit = Integer.parseInt(value); + else{ + fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT; + } + } catch (Exception ex){ + fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT; + } + // setup dispatcher setScannerState(SCANNER_STATE_CONTENT); setDispatcher(fContentDispatcher); @@ -799,7 +819,12 @@ // attributes scanAttribute(fAttributes); - + if (fAttributes.getLength() > fElementAttributeLimit){ + fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, + "ElementAttributeLimit", + new Object[]{rawname, new Integer(fElementAttributeLimit) }, + XMLErrorReporter.SEVERITY_FATAL_ERROR ); + } } while (true); // call handler No revision No revision 1.16.2.1 +1 -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.16 retrieving revision 1.16.2.1 diff -u -r1.16 -r1.16.2.1 --- XMLMessages.properties 8 Jan 2003 23:04:11 -0000 1.16 +++ XMLMessages.properties 27 Jan 2004 08:00:01 -0000 1.16.2.1 @@ -279,3 +279,4 @@ #Application can set the limit of number of entities that should be expanded by the parser. EntityExpansionLimitExceeded=The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the application. +ElementAttributeLimit= Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the application.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]