Skip to content
Snippets Groups Projects
Commit 6b5c53b0 authored by Jack Nagel's avatar Jack Nagel
Browse files

gist-logs: fix up encoding before passing the response body to OkJson

Fixes Homebrew/homebrew#30519.
parent 7cd31377
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment