From: Yegor Kozlov Date: Mon, 16 Jul 2012 15:32:25 +0000 (+0000) Subject: Bugzilla 53360 - Fixed SXSSF to correctly write text before escaped Unicode control... X-Git-Tag: 3.10-beta1~172 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=681d7bd1b837a4806da7c1eaced8f5729aef1715;p=poi.git Bugzilla 53360 - Fixed SXSSF to correctly write text before escaped Unicode control character git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1362093 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 1369190d9f..01c8b08919 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 53360 - Fixed SXSSF to correctly write text before escaped Unicode control character Change HSMF Types to have full data on ID, Name and Length, rather than just being a simple ID 48469 - Updated case study 53476 - Support Complex Name in formulas 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 521f9d56ee..f6c98317f5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java @@ -278,6 +278,9 @@ public class SheetDataWriter { // the same rule applies to unicode surrogates and "not a character" symbols. if( c < ' ' || Character.isLowSurrogate(c) || Character.isHighSurrogate(c) || ('\uFFFE' <= c && c <= '\uFFFF')) { + if (counter > last) { + _out.write(chars, last, counter - last); + } _out.write('?'); last = counter + 1; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java index 72258e411c..ef9149cbf8 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -154,6 +154,14 @@ public final class TestSXSSFWorkbook extends BaseTestWorkbook { tmp = wr.getTempFile(); assertTrue(tmp.getName().startsWith("poi-sxssf-sheet-xml")); assertTrue(tmp.getName().endsWith(".gz")); + + //Test escaping of Unicode control characters + wb = new SXSSFWorkbook(); + wb.createSheet("S1").createRow(0).createCell(0).setCellValue("value\u0019"); + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); + Cell cell = xssfWorkbook.getSheet("S1").getRow(0).getCell(0); + assertEquals("value?", cell.getStringCellValue()); + } public void testGZipSheetdataWriter(){