Sanitize groupname

Backport to stable45 of #2060