diff options
author | Dominik Stadler <centic@apache.org> | 2016-11-25 22:07:59 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2016-11-25 22:07:59 +0000 |
commit | 3bda549d79970ee668eee240558159b0d95c2f8b (patch) | |
tree | 2d5f8b09d1a5b1d1562963630cd224f93fab0aa8 /src/testcases/org | |
parent | d58dd553dcb6060c222d52c15ed0b0409bee3092 (diff) | |
download | poi-3bda549d79970ee668eee240558159b0d95c2f8b.tar.gz poi-3bda549d79970ee668eee240558159b0d95c2f8b.zip |
Bug 60370: Encode some special characters when setting title/text for validation text-boxes, for now all characters below 32, more can be added if necessary.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1771396 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index 309155ca2d..4d465499ac 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -53,6 +53,8 @@ public abstract class BaseTestBugzillaIssues { private static final String TEST_32 = "Some text with 32 characters to "; private static final String TEST_255 = "Some very long text that is exactly 255 characters, which are allowed here, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla....."; private static final String TEST_256 = "Some very long text that is longer than the 255 characters allowed in HSSF here, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla bla, bla1"; + private static final String TEST_SPECIAL_TITLE = "special \n\t\r\u0002characters"; + private static final String TEST_SPECIAL = "Some text with special \n\t\r\u0002characters to s"; private final ITestDataProvider _testDataProvider; @@ -167,7 +169,7 @@ public abstract class BaseTestBugzillaIssues { // fetch the first merged region...EXCEPTION OCCURS HERE template.getMergedRegion(0); } - //make sure we dont exception + wb.close(); } @@ -989,7 +991,7 @@ public abstract class BaseTestBugzillaIssues { * With HSSF, if you create a font, don't change it, and * create a 2nd, you really do get two fonts that you * can alter as and when you want. - * With XSSF, that wasn't the case, but this verfies + * With XSSF, that wasn't the case, but this verifies * that it now is again */ @Test @@ -1802,9 +1804,14 @@ public abstract class BaseTestBugzillaIssues { // more than 255 fail for all checkFailures(dataValidation, TEST_256, TEST_32, true); checkFailures(dataValidation, TEST_32, TEST_256, true); + // more than 32 title fail for HSSFWorkbook checkFailures(dataValidation, TEST_255, TEST_32, wb instanceof HSSFWorkbook); - // 32 length title and 255 length text wrok for both + + // special characters work + checkFailures(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL, false); + + // 32 length title and 255 length text work for both checkFailures(dataValidation, TEST_32, TEST_255, false); dataValidation.setShowErrorBox(false); @@ -1843,4 +1850,38 @@ public abstract class BaseTestBugzillaIssues { assertTrue("Should not fail in a length-check, had " + title.length() + " and " + text.length(), shouldFail); } } + + @Test + public void test60370() throws IOException { + Workbook wb = _testDataProvider.createWorkbook(); + final Sheet sheet = wb.createSheet(); + + DataValidation dataValidation; + CellRangeAddressList headerCell = new CellRangeAddressList(0, 1, 0, 1); + DataValidationConstraint constraint = sheet.getDataValidationHelper().createCustomConstraint("A1<>\"\""); + + dataValidation = sheet.getDataValidationHelper().createValidation(constraint, headerCell); + checkFailures(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL, false); + + dataValidation.setShowErrorBox(true); + dataValidation.setShowPromptBox(true); + sheet.addValidationData(dataValidation); + + // write out and read back in to trigger some more validation + final Workbook wbBack = _testDataProvider.writeOutAndReadBack(wb); + + final Sheet sheetBack = wbBack.getSheetAt(0); + final List<? extends DataValidation> dataValidations = sheetBack.getDataValidations(); + assertEquals(1, dataValidations.size()); + + /*String ext = (wb instanceof HSSFWorkbook) ? ".xls" : ".xlsx"; + OutputStream str = new FileOutputStream("/tmp/60370" + ext); + try { + wb.write(str); + } finally { + str.close(); + }*/ + + wb.close(); + } }
\ No newline at end of file |