Skip to content

Commit 24ec0e8

Browse files
committed
feat(AppManager): log when cleanAppId drops invalid chars
Log a debug message if invalid characters are replaced in app IDs. Signed-off-by: Josh <[email protected]>
1 parent 6a2e0f8 commit 24ec0e8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/private/App/AppManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,13 @@ public function isBackendRequired(string $backend): bool {
10311031
*/
10321032
public function cleanAppId(string $app): string {
10331033
/* Only lowercase alphanumeric is allowed */
1034-
return preg_replace('/(^[0-9_-]+|[^a-z0-9_-]+|[_-]+$)/', '', $app);
1034+
$cleanAppId = preg_replace('/(^[0-9_-]+|[^a-z0-9_-]+|[_-]+$)/', '', $app, -1, $count);
1035+
if ($count > 0) {
1036+
$this->logger->debug('Only lowercase alphanumeric characters are allowed in appIds; check paths of installed app [' . $count . ' characters replaced]', [
1037+
'app' => $cleanAppId, // safer to log $cleanAppId even if it makes more challenging to troubleshooting (part of why character count is at least logged)
1038+
]);
1039+
}
1040+
return $cleanAppId;
10351041
}
10361042

10371043
/**

0 commit comments

Comments
 (0)