ostap/comp — pull request #29 by julochrobak (2013-12-22 15:01:16+00:00)
Title: Invalid JSON response if data contains control or non-printable characters.

The JSON response is created with a help of strconv.Quote function. From the golang documentation, the Quote returns a double-quoted Go string literal representing s. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for control characters and non-printable characters as defined by IsPrint. However, the "\xFF" cannot be used in JSON string literals.

Here is an example:

$ bin/comp '{id: "^A"}'
{ "id": "\x01" }
$ bin/comp '{id: "^A"}' | bin/comp -f @json 'in'
failed to load in.json: invalid character 'x' in string escape code