Tighten up the check for allowed key and group names. (#343191, Tommi