feat(AppManager): log when cleanAppId drops invalid chars

Log a debug message if invalid characters are replaced in app IDs.

Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
Josh 2025-11-18 17:26:01 -05:00
parent 6a2e0f819c
commit 24ec0e85e5

View file

@ -1031,7 +1031,13 @@ class AppManager implements IAppManager {
*/
public function cleanAppId(string $app): string {
/* Only lowercase alphanumeric is allowed */
return preg_replace('/(^[0-9_-]+|[^a-z0-9_-]+|[_-]+$)/', '', $app);
$cleanAppId = preg_replace('/(^[0-9_-]+|[^a-z0-9_-]+|[_-]+$)/', '', $app, -1, $count);
if ($count > 0) {
$this->logger->debug('Only lowercase alphanumeric characters are allowed in appIds; check paths of installed app [' . $count . ' characters replaced]', [
'app' => $cleanAppId, // safer to log $cleanAppId even if it makes more challenging to troubleshooting (part of why character count is at least logged)
]);
}
return $cleanAppId;
}
/**