From: Alexandre Rossi <alexandre.rossi@gmail.com>
Subject: Fix compilation with woodstox 5
Forwarded: https://sourceforge.net/p/davmail/feature-requests/115/

--- davmail.git.orig/src/java/com/ctc/wstx/sr/StreamScanner.java	2014-08-30 18:14:09.000000000 +0200
+++ davmail.git/src/java/com/ctc/wstx/sr/StreamScanner.java	2018-06-25 15:03:33.399476591 +0200
@@ -413,7 +413,7 @@
                                   mInputPtr - mCurrInputRowStart);
     }
 
-    protected URL getSource() {
+    protected URL getSource() throws IOException {
         return mInput.getSource();
     }
 
@@ -959,7 +959,12 @@
          * error reporting etc.
          */
         mInputTopDepth = mCurrDepth;
-        mInput.initInputLocation(this, mCurrDepth);
+        // [WSTX-296]: Check for entity expansion depth against configurable
+        // limit
+        int entityDepth = mInput.getEntityDepth() + 1;
+        verifyLimit("Maximum entity expansion depth", mConfig.getMaxEntityDepth(), entityDepth);
+        mInput = newInput;
+        mInput.initInputLocation(this, mCurrDepth, entityDepth);
 
         /* 21-Feb-2006, TSa: Linefeeds are NOT normalized when expanding
          *   internal entities (XML, 2.11)
@@ -2449,4 +2454,18 @@
     {
         throwParseError("Illegal character entity: expansion character (code 0x{0}", Integer.toHexString(value), null);
     }
+
+    protected void verifyLimit(String type, long maxValue, long currentValue)
+        throws XMLStreamException
+    {
+        if (currentValue > maxValue) {
+            throw constructLimitViolation(type, maxValue);
+        }
+    }
+
+    protected XMLStreamException constructLimitViolation(String type, long limit)
+        throws XMLStreamException
+    {
+        return new XMLStreamException(type+" limit ("+limit+") exceeded");
+	}
 }
