Improve escaping logic

`bear_json_escape_string` currently combines JSON escaping and shell escaping, and does neither thoroughly. This separates them and completes both.