aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2016-04-06 19:50:08 +0000
committerDominik Stadler <centic@apache.org>2016-04-06 19:50:08 +0000
commitcb911c4b9ada3c60272f52fd40e383f7c984d7df (patch)
tree51bf79260ec02ddbc8ab8cfd9be09ad2f8f9fdc3 /src/java
parentabf2f2947862a96544e6f5cfeb7ca0e524b96ae7 (diff)
downloadpoi-cb911c4b9ada3c60272f52fd40e383f7c984d7df.tar.gz
poi-cb911c4b9ada3c60272f52fd40e383f7c984d7df.zip
Bug 58648: Fix handling whitespaces in formulas, unfortunately blank can be the intersection operator as well, so we need to try and skip it as whitespace if intersection fails which can lead to hard to track bugs or misleading error messages with some formulas
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1738033 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/ss/formula/FormulaParser.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/ss/formula/FormulaParser.java b/src/java/org/apache/poi/ss/formula/FormulaParser.java
index f2430a90be..8e5d8e999a 100644
--- a/src/java/org/apache/poi/ss/formula/FormulaParser.java
+++ b/src/java/org/apache/poi/ss/formula/FormulaParser.java
@@ -1530,11 +1530,19 @@ public final class FormulaParser {
while (true) {
SkipWhite();
if (_inIntersection) {
+ int savePointer = _pointer;
+
// Don't getChar() as the space has already been eaten and recorded by SkipWhite().
- hasIntersections = true;
- ParseNode other = comparisonExpression();
- result = new ParseNode(IntersectionPtg.instance, result, other);
- continue;
+ try {
+ ParseNode other = comparisonExpression();
+ result = new ParseNode(IntersectionPtg.instance, result, other);
+ hasIntersections = true;
+ continue;
+ } catch (FormulaParseException e) {
+ // if parsing for intersection fails we assume that we actually had an arbitrary
+ // whitespace and thus should simply skip this whitespace
+ resetPointer(savePointer);
+ }
}
if (hasIntersections) {
return augmentWithMemPtg(result);