Fix NPE when converting invalid color character from legacy text (Fixes #934)

Removes all invalid color codes from the string that is converted.