Remove invalid characters from app id to prevent loading of invalid ress...

...ources.

Backport of #1569