Support UTF-8 Table names

Added support for UTF-8 Table names (including
combined character)
This commit is contained in:
aswinkumar863 2022-04-17 17:41:49 +05:30
parent 59083263e1
commit 8889ecf044
No known key found for this signature in database
GPG Key ID: 8A69BFA6AEF8FA3E
2 changed files with 5 additions and 2 deletions

View File

@ -103,10 +103,10 @@ class Table
) {
throw new PhpSpreadsheetException('The table name can\'t be the same as a cell reference');
}
if (!preg_match('/^[A-Z_\\\\]/i', $name)) {
if (!preg_match('/^[\p{L}_\\\\]/iu', $name)) {
throw new PhpSpreadsheetException('The table name must begin a name with a letter, an underscore character (_), or a backslash (\)');
}
if (!preg_match('/^[A-Z_\\\\][A-Z0-9\._]+$/i', $name)) {
if (!preg_match('/^[\p{L}_\\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
throw new PhpSpreadsheetException('The table name contains invalid characters');
}

View File

@ -42,6 +42,8 @@ class TableTest extends SetupTeardown
['_table_2', '_table_2'],
['\table_3', '\table_3'],
[" Table_4 \n", 'Table_4'],
['table.5', 'table.5'],
['தமிழ்', 'தமிழ்'], // UTF-8 letters with combined character
];
}
@ -72,6 +74,7 @@ class TableTest extends SetupTeardown
['R11C11'],
['123'],
['=Table'],
['ிக'], // starting with UTF-8 combined character
[bin2hex(random_bytes(255))], // random string with length greater than 255
];
}