Remove illegal characters from commands