Skip to content

Commit 851dfdb

Browse files
author
Hannes Funk
committed
MBS-10346: Add validation for tenant identifier
1 parent 88c7b31 commit 851dfdb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

classes/local/tenant.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class tenant {
3737
* Tenant class constructor.
3838
*
3939
* @param string $identifier the tenant identifier; if left empty, the default tenant is being used
40+
* @throws \invalid_parameter_exception If the provided identifier contains invalid characters
4041
*/
4142
public function __construct(string $identifier = '') {
4243
global $USER;
@@ -47,6 +48,12 @@ public function __construct(string $identifier = '') {
4748
$identifier = self::DEFAULT_IDENTIFIER;
4849
}
4950
}
51+
52+
if (!preg_match('/^[A-Za-z0-9_\- ]+$/', $identifier)) {
53+
$debuginfo = 'Tenant identifiers can only contain alphanumeric letters, hyphens, underscores or blank spaces.';
54+
throw new \invalid_parameter_exception($debuginfo);
55+
}
56+
5057
$this->identifier = $identifier;
5158
}
5259

0 commit comments

Comments
 (0)