ASF Bugzilla – Attachment 37361 Details for
Bug 64595
[PATCH] Missing quoting of pre-evaluated string values in formula cells causes corrupt files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Plain text patch to quote cell values for formula cells with pre-evaluated string contents
64595.patch (text/plain), 2.59 KB, created by
Bastian Isensee
on 2020-07-13 17:20:08 UTC
(
hide
)
Description:
Plain text patch to quote cell values for formula cells with pre-evaluated string contents
Filename:
MIME Type:
Creator:
Bastian Isensee
Created:
2020-07-13 17:20:08 UTC
Size:
2.59 KB
patch
obsolete
>diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java >index 8cf5cbc0e..fa3f9e135 100644 >--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java >+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java >@@ -298,7 +298,7 @@ public class SheetDataWriter implements Closeable { > String value = cell.getStringCellValue(); > if(value != null && !value.isEmpty()) { > _out.write("<v>"); >- _out.write(value); >+ outputQuotedString(value); > _out.write("</v>"); > } > break; >diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java >index 174b1c490..76716abb0 100644 >--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java >+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java >@@ -47,6 +47,7 @@ import org.junit.Test; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType; > > public final class TestSXSSFBugs extends BaseTestBugzillaIssues { >+ > public TestSXSSFBugs() { > super(SXSSFITestDataProvider.instance); > } >@@ -238,4 +239,31 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues { > } > } > } >+ >+ @Test >+ public void test64595() throws Exception { >+ try (Workbook workbook = new SXSSFWorkbook(100)) { >+ Sheet sheet = workbook.createSheet("RawData"); >+ Row row = sheet.createRow(0); >+ Cell cell; >+ >+ cell = row.createCell(0); >+ cell.setCellValue("Ernie & Bert"); >+ >+ cell = row.createCell(1); >+ // Set a precalculated formula value containing a special character. >+ cell.setCellValue("Ernie & Bert are cool!"); >+ cell.setCellFormula("A1 & \" are cool!\""); >+ >+ // While unfixed reading the workbook would throw a POIXMLException >+ // since the file was corrupt due to missing quotation. >+ try (Workbook wbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook)) { >+ assertNotNull(wbBack); >+ cell = wbBack.getSheetAt(0).getRow(0).getCell(1); >+ assertEquals("Ernie & Bert are cool!", cell.getStringCellValue()); >+ assertEquals("A1 & \" are cool!\"", cell.getCellFormula()); >+ } >+ } >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 64595
:
37360
| 37361