]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 52583 - fixed WorkbookUtil#createSafeSheetName to escape colon
authorYegor Kozlov <yegor@apache.org>
Mon, 27 Feb 2012 15:21:40 +0000 (15:21 +0000)
committerYegor Kozlov <yegor@apache.org>
Mon, 27 Feb 2012 15:21:40 +0000 (15:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1294180 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/WorkbookUtil.java
src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java

index 767e1327e28fe094bb55cb0cbca474be90dc6f40..8008844b8a0718d748dbd94c1cdd05cf7d20416d 100644 (file)
@@ -35,7 +35,7 @@ public class WorkbookUtil {
         * <li>never null</li>
         * <li>minimum length is 1</li>
         * <li>maximum length is 31</li>
-        * <li>doesn't contain special chars: / \ ? * ] [ </li>
+        * <li>doesn't contain special chars: : 0x0000, 0x0003, / \ ? * ] [ </li>
         * <li>Sheet names must not begin or end with ' (apostrophe)</li>
         * </ul>
         * Invalid characters are replaced by one space character ' '.
@@ -57,6 +57,9 @@ public class WorkbookUtil {
                for (int i=0; i<length; i++) {
                        char ch = result.charAt(i);
                        switch (ch) {
+                case '\u0000':
+                case '\u0003':
+                case ':':
                                case '/':
                                case '\\':
                                case '?':
index c1e49cab674bb18fe743deb350fe935742c15d34..2bd305c4333703df5498cb1b807af010eb024624 100644 (file)
@@ -80,5 +80,8 @@ public final class TestWorkbookUtil extends TestCase {
                
                actual = WorkbookUtil.createSafeSheetName("1234567890123456789012345678901TOOLONG");
                assertEquals("1234567890123456789012345678901", actual);
+
+        actual = WorkbookUtil.createSafeSheetName("sheet:a4");
+        assertEquals("sheet a4", actual);
        }
 }