diff options
| author | Jack Nagel | 2014-06-28 17:34:42 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-06-28 17:35:58 -0500 |
| commit | c15ad2625757140a05ede4b13029b60adaca03a0 (patch) | |
| tree | 929d61104938def28d1e288fd13657d55821e54e /Library | |
| parent | 7a901c7ebde5e2aabf99289743ead2650caf5fcf (diff) | |
| download | homebrew-c15ad2625757140a05ede4b13029b60adaca03a0.tar.bz2 | |
gist-logs: fix up encoding before passing the response body to OkJson
Fixes #30519.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/cmd/brew-gist-logs.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Library/Contributions/cmd/brew-gist-logs.rb b/Library/Contributions/cmd/brew-gist-logs.rb index fe71865f3..d36567f3e 100755 --- a/Library/Contributions/cmd/brew-gist-logs.rb +++ b/Library/Contributions/cmd/brew-gist-logs.rb @@ -76,7 +76,14 @@ def post path, data request.body = Utils::JSON.dump(data) response = http.request(request) raise HTTP_Error, response if response.code != '201' - Utils::JSON.load(response.body) + + if response["Content-Type"].downcase == "application/json; charset=utf-8" + body = response.body.dup.force_encoding(Encoding::UTF_8) + else + body = response.body.encode(Encoding::UTF_8, undef: :replace) + end + + Utils::JSON.load(body) end class HTTP_Error < RuntimeError |
