diff options
Diffstat (limited to 'src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java')
-rw-r--r-- | src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java b/src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java index 1b55599..bd19dff 100644 --- a/src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java +++ b/src/com/sun/org/apache/xpath/internal/compiler/XPathParser.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Copyright 1999-2004 The Apache Software Foundation. @@ -37,6 +36,7 @@ import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; * Tokenizes and parses XPath expressions. This should really be named * XPathParserImpl, and may be renamed in the future. * @xsl.usage general + * @LastModified: May 2019 */ public class XPathParser { @@ -74,6 +74,9 @@ public class XPathParser protected final static int FILTER_MATCH_PRIMARY = 1; protected final static int FILTER_MATCH_PREDICATES = 2; + // counts open predicates + private int countPredicate; + /** * The parser constructor. */ @@ -160,6 +163,9 @@ public class XPathParser } else throw e; + } catch (StackOverflowError sof) { + error(XPATHErrorResources.ER_PREDICATE_TOO_MANY_OPEN, + new Object[]{m_token, m_queueMark, countPredicate}); } compiler.shrink(); @@ -193,7 +199,12 @@ public class XPathParser m_ops.setOp(OpMap.MAPINDEX_LENGTH, 2); nextToken(); - Pattern(); + try { + Pattern(); + } catch (StackOverflowError sof) { + error(XPATHErrorResources.ER_PREDICATE_TOO_MANY_OPEN, + new Object[]{m_token, m_queueMark, countPredicate}); + } if (null != m_token) { @@ -789,7 +800,7 @@ public class XPathParser */ protected void Expr() throws javax.xml.transform.TransformerException { - OrExpr(); + OrExpr(); } /** @@ -1931,11 +1942,12 @@ public class XPathParser */ protected void Predicate() throws javax.xml.transform.TransformerException { - if (tokenIs('[')) { + countPredicate++; nextToken(); PredicateExpr(); + countPredicate--; consumeExpected(']'); } } |