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
This commit is contained in:
Yegor Kozlov 2012-02-27 15:21:40 +00:00
parent a03a39fd54
commit 828ee0cf88
2 changed files with 7 additions and 1 deletions

View 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 '?':

View 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);
}
}