diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-08-10 09:38:39 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-08-10 09:38:39 +0000 |
commit | d15286103648b5cbfadfc6eeec132f224b49e2ec (patch) | |
tree | f8d8f3467f4a81c1513619fda8838c904812d40e /poi/src | |
parent | a6a37bd0f012a4ccfca3760418bf53ca5da65a4c (diff) | |
download | poi-d15286103648b5cbfadfc6eeec132f224b49e2ec.tar.gz poi-d15286103648b5cbfadfc6eeec132f224b49e2ec.zip |
[bug-66855] Formula parser incorrectly handles sheet name containing multiple single quotes in a row. Thanks to Kirill lebedev. This closes #496
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911589 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/FormulaParser.java | 2 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParser.java | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/FormulaParser.java b/poi/src/main/java/org/apache/poi/ss/formula/FormulaParser.java index 83fe1051af..28d13bfbc8 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/FormulaParser.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/FormulaParser.java @@ -1182,8 +1182,6 @@ public final class FormulaParser { if (look == '\''){ // Any single quotes which were already present in the sheet name will be converted to double single quotes ('') // so switch back to single quote - sb.appendCodePoint(look); - nextChar(); break; } } diff --git a/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParser.java b/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParser.java index 2a3cb6c98c..40c96991bf 100644 --- a/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParser.java +++ b/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParser.java @@ -1372,6 +1372,22 @@ final class TestFormulaParser { } @Test + void testParseSheetNameWithMultipleSingleQuotes() throws IOException { + try (HSSFWorkbook wb = new HSSFWorkbook()) { + wb.createSheet("Sh''t1"); + Ptg[] ptgs = parse("'Sh''''t1'!$A:$A,'Sh''''t1'!$1:$4", wb); + confirmTokenClasses(ptgs, + MemFuncPtg.class, + Area3DPtg.class, + Area3DPtg.class, + UnionPtg.class + ); + assertEquals(0, ((Area3DPtg)ptgs[1]).getExternSheetIndex()); + assertEquals(0, ((Area3DPtg)ptgs[2]).getExternSheetIndex()); + } + } + + @Test void testExplicitRangeWithTwoSheetNames() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); wb.createSheet("Sheet1"); |