From: Luis Bernardo Date: Fri, 12 Jul 2013 23:02:02 +0000 (+0000) Subject: FOP-2271: XSL Infinite loop; patch submitted by Simon Steiner. X-Git-Tag: fop-2_0~195 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c078247bdc67632eb9e6fda7fa3ea19513241220;p=xmlgraphics-fop.git FOP-2271: XSL Infinite loop; patch submitted by Simon Steiner. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1502722 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 84d03db83..49694eebd 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -83,6 +83,7 @@ public class FOTreeBuilder extends DefaultHandler { private boolean empty = true; private int depth; + private boolean errorinstart; /** * FOTreeBuilder 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); + } } } }