Encode everything except a whitelist of special chars

see #2406