File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff 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,11 @@ public function __construct(string $identifier = '') {
4748 $ identifier = self ::DEFAULT_IDENTIFIER ;
4849 }
4950 }
51+
52+ if (!preg_match ('/^[A-Za-z0-9_\- ]+$/ ' , $ identifier )) {
53+ throw new \invalid_parameter_exception ('Invalid tenant identifier. Tenant identifiers can only contain alphanumeric letters, hyphens, underscores or blank spaces. ' );
54+ }
55+
5056 $ this ->identifier = $ identifier ;
5157 }
5258
@@ -139,4 +145,4 @@ public function get_defaultfullname(): string {
139145 ? get_string ('defaulttenantname ' , 'local_ai_manager ' )
140146 : $ this ->identifier ;
141147 }
142- }
148+ }
You can’t perform that action at this time.
0 commit comments