]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2271: XSL Infinite loop; patch submitted by Simon Steiner.
authorLuis Bernardo <lbernardo@apache.org>
Fri, 12 Jul 2013 23:02:02 +0000 (23:02 +0000)
committerLuis Bernardo <lbernardo@apache.org>
Fri, 12 Jul 2013 23:02:02 +0000 (23:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1502722 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/FOTreeBuilder.java

index 84d03db83edad08d17686ff1f5c1d92f3b94f577..49694eebd9ad6e40e25a04c905e119af921e0ac6 100644 (file)
@@ -83,6 +83,7 @@ public class FOTreeBuilder extends DefaultHandler {
     private boolean empty = true;
 
     private int depth;
+    private boolean errorinstart;
 
     /**
      * <code>FOTreeBuilder</code> constructor
@@ -172,20 +173,28 @@ public class FOTreeBuilder extends DefaultHandler {
     public void startElement(String namespaceURI, String localName, String rawName,
                              Attributes attlist) throws SAXException {
         this.depth++;
-        delegate.startElement(namespaceURI, localName, rawName, attlist);
+        errorinstart = false;
+        try {
+            delegate.startElement(namespaceURI, localName, rawName, attlist);
+        } catch (SAXException e) {
+            errorinstart = true;
+            throw e;
+        }
     }
 
     /** {@inheritDoc} */
     public void endElement(String uri, String localName, String rawName)
                 throws SAXException {
-        this.delegate.endElement(uri, localName, rawName);
-        this.depth--;
-        if (depth == 0) {
-            if (delegate != mainFOHandler) {
-                //Return from sub-handler back to main handler
-                delegate.endDocument();
-                delegate = mainFOHandler;
-                delegate.endElement(uri, localName, rawName);
+        if (!errorinstart) {
+            this.delegate.endElement(uri, localName, rawName);
+            this.depth--;
+            if (depth == 0) {
+                if (delegate != mainFOHandler) {
+                    //Return from sub-handler back to main handler
+                    delegate.endDocument();
+                    delegate = mainFOHandler;
+                    delegate.endElement(uri, localName, rawName);
+                }
             }
         }
     }