aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-27 15:21:40 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-27 15:21:40 +0000
commit3b7638611bdd4e9d9b3dfcbb229c902f28da5710 (patch)
tree7b2f73f6db9505402021e74a603bcd9563231644 /src
parenta6f40e2952bfaad335e670192b3b51a963c04d08 (diff)
downloadpoi-3b7638611bdd4e9d9b3dfcbb229c902f28da5710.tar.gz
poi-3b7638611bdd4e9d9b3dfcbb229c902f28da5710.zip
Bugzilla 52583 - fixed WorkbookUtil#createSafeSheetName to escape colon
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1294180 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/ss/util/WorkbookUtil.java5
-rw-r--r--src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java3
2 files changed, 7 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/ss/util/WorkbookUtil.java b/src/java/org/apache/poi/ss/util/WorkbookUtil.java
index 767e1327e2..8008844b8a 100644
--- a/src/java/org/apache/poi/ss/util/WorkbookUtil.java
+++ b/src/java/org/apache/poi/ss/util/WorkbookUtil.java
@@ -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 '?':
diff --git a/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java b/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java
index c1e49cab67..2bd305c433 100644
--- a/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java
+++ b/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java
@@ -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);
}
}