]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 53360 - Fixed SXSSF to correctly write text before escaped Unicode control...
authorYegor Kozlov <yegor@apache.org>
Mon, 16 Jul 2012 15:32:25 +0000 (15:32 +0000)
committerYegor Kozlov <yegor@apache.org>
Mon, 16 Jul 2012 15:32:25 +0000 (15:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1362093 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java

index 1369190d9fe56748bf202f108a0e3a9b7439e0d5..01c8b089191e29e1f781ea87bf6dda199ac78def 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="fix">53360 - Fixed SXSSF to correctly write text before escaped Unicode control character</action>
           <action dev="poi-developers" type="add">Change HSMF Types to have full data on ID, Name and Length, rather than just being a simple ID</action>
           <action dev="poi-developers" type="add">48469 - Updated case study</action>
           <action dev="poi-developers" type="add">53476 - Support Complex Name in formulas </action>
index 521f9d56eeba744d5b65a688c80673d582ce101c..f6c98317f54a2dfffd42747886b0ec68cea78d24 100644 (file)
@@ -278,6 +278,9 @@ public class SheetDataWriter {
                     // the same rule applies to unicode surrogates and "not a character" symbols.\r
                     if( c < ' ' || Character.isLowSurrogate(c) || Character.isHighSurrogate(c) ||\r
                             ('\uFFFE' <= c && c <= '\uFFFF')) {\r
+                        if (counter > last) {\r
+                            _out.write(chars, last, counter - last);\r
+                        }\r
                         _out.write('?');\r
                         last = counter + 1;\r
                     }\r
index 72258e411caeb078931078f5a59b5ed90305b9b2..ef9149cbf8e1738d8b66e7b83e39e6af67cd12aa 100644 (file)
@@ -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(){