@@ -46,6 +46,9 @@ public final class ReaderConfig
4646 public final static int DEFAULT_MAX_ENTITY_DEPTH = 500 ;
4747 public final static int DEFAULT_MAX_ENTITY_COUNT = 100 * 1000 ;
4848
49+ // @since 5.4/6.4
50+ public final static int DEFAULT_MAX_DTD_DEPTH = 500 ;
51+
4952 /*
5053 ///////////////////////////////////////////////////////////////////////
5154 // Constants for reader properties:
@@ -133,7 +136,9 @@ public final class ReaderConfig
133136 final static int PROP_MAX_TEXT_LENGTH = 66 ;
134137 final static int PROP_MAX_ENTITY_COUNT = 67 ;
135138 final static int PROP_MAX_ENTITY_DEPTH = 68 ;
136-
139+
140+ final static int PROP_MAX_DTD_DEPTH = 69 ;
141+
137142 /*
138143 ////////////////////////////////////////////////
139144 // Limits for numeric properties
@@ -341,6 +346,10 @@ public final class ReaderConfig
341346 PROP_MAX_ENTITY_DEPTH );
342347 sProperties .put (WstxInputProperties .P_MAX_ENTITY_COUNT ,
343348 PROP_MAX_ENTITY_COUNT );
349+ // since 5.4/6.4
350+ sProperties .put (WstxInputProperties .P_MAX_DTD_DEPTH ,
351+ PROP_MAX_DTD_DEPTH );
352+
344353 sProperties .put (WstxInputProperties .P_MAX_CHARACTERS , PROP_MAX_CHARACTERS );
345354 sProperties .put (WstxInputProperties .P_CUSTOM_INTERNAL_ENTITIES ,
346355 Integer .valueOf (PROP_CUSTOM_INTERNAL_ENTITIES ));
@@ -400,6 +409,9 @@ public final class ReaderConfig
400409
401410 protected int mMaxEntityDepth = DEFAULT_MAX_ENTITY_DEPTH ;
402411 protected long mMaxEntityCount = DEFAULT_MAX_ENTITY_COUNT ;
412+
413+ // since 5.4/6.4
414+ protected int mMaxDtdDepth = DEFAULT_MAX_DTD_DEPTH ;
403415
404416 /**
405417 * Base URL to use as the resolution context for relative entity
@@ -506,6 +518,7 @@ private ReaderConfig(ReaderConfig base,
506518 mMaxTextLength = base .mMaxTextLength ;
507519 mMaxEntityDepth = base .mMaxEntityDepth ;
508520 mMaxEntityCount = base .mMaxEntityCount ;
521+ mMaxDtdDepth = base .mMaxDtdDepth ;
509522 }
510523
511524 /* Ok, let's then see if we can find a buffer recycler. Since they
@@ -569,6 +582,7 @@ public ReaderConfig createNonShared(SymbolTable sym)
569582 rc .mMaxElementDepth = mMaxElementDepth ;
570583 rc .mMaxEntityDepth = mMaxEntityDepth ;
571584 rc .mMaxEntityCount = mMaxEntityCount ;
585+ rc .mMaxDtdDepth = mMaxDtdDepth ;
572586 if (mSpecialProperties != null ) {
573587 int len = mSpecialProperties .length ;
574588 Object [] specProps = new Object [len ];
@@ -735,6 +749,8 @@ public boolean willAllowXml11EscapedCharsInXml10() {
735749 public int getMaxEntityDepth () { return mMaxEntityDepth ; }
736750 public long getMaxEntityCount () { return mMaxEntityCount ; }
737751
752+ public int getMaxDtdDepth () { return mMaxDtdDepth ; }
753+
738754 public long getMaxCharacters () { return mMaxCharacters ; }
739755 public long getMaxTextLength () { return mMaxTextLength ; }
740756
@@ -1000,6 +1016,10 @@ public void setMaxEntityDepth(int value) {
10001016 public void setMaxEntityCount (long value ) {
10011017 mMaxEntityCount = value ;
10021018 }
1019+ // @since 5.4/6.4
1020+ public void setMaxDtdDepth (int value ) {
1021+ mMaxDtdDepth = value ;
1022+ }
10031023
10041024 public void setCustomInternalEntities (Map <String ,?> m )
10051025 {
@@ -1498,6 +1518,8 @@ public Object getProperty(int id)
14981518 return getMaxEntityDepth ();
14991519 case PROP_MAX_ENTITY_COUNT :
15001520 return getMaxEntityCount ();
1521+ case PROP_MAX_DTD_DEPTH :
1522+ return getMaxDtdDepth ();
15011523
15021524 case PROP_MIN_TEXT_SEGMENT :
15031525 return getShortestReportedTextSegment ();
@@ -1686,6 +1708,9 @@ public boolean setProperty(String propName, int id, Object value)
16861708 case PROP_MAX_ENTITY_COUNT :
16871709 setMaxEntityCount (ArgUtil .convertToLong (propName , value , 1 ));
16881710 break ;
1711+ case PROP_MAX_DTD_DEPTH :
1712+ setMaxDtdDepth (ArgUtil .convertToInt (propName , value , 1 ));
1713+ break ;
16891714
16901715 case PROP_MIN_TEXT_SEGMENT :
16911716 setShortestReportedTextSegment (ArgUtil .convertToInt (propName , value , 1 ));
0 commit comments