CPAN-API/cpan-api — pull request #189 by grantm (2012-04-03 18:54:44+00:00)
Title: Fix double encoding in JSONP view

The output of the JSON encoding is a UTF8 *byte* string. Somewhere in the Plack output pipeline, this response body is being treated as if it were a character string and re-encoded to UTF8. This results in the bytes of each multi-byte character being converted to multi-byte characters.

For an example, this changelog file includes the name "König" on line 13

http://api.metacpan.org/source/GRANTM/XML-Simple-2.18/Changes

When the same file is requested via JSONP, the name comes out as "K\xC3\x83\xC2\xB6nig"

http://api.metacpan.org/source/GRANTM/XML-Simple-2.18/Changes?callback=foo

This commit tweaks the JSON encoding line to produce plain ASCII output (e.g.: "K\U00F6nig") which survives the later UTF8 encoding.