Skip to content
This repository

missing response.setEncoding('utf8') #119

Open
wants to merge 1 commit into from

1 participant

Jacky Zhao
Jacky Zhao

I thought oauth2.js missed one line response.setEncoding('utf8'), the oauh.js has this line.

But missing the line, the chunk is a buffer, and result+= chunk will cause encoding problem. Because one char in utf8 (one char in may bytes) maybe separated into two buffers. and result+=chunk implies chunk convert to string first, so one good char becomes two broken char.

This is the same problem as issues #118, and I think pull request #80 is a good idea, but it should be applied to oauth2.js as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 28, 2012
Jacky Zhao jackyz add response.setEncoding 216a8b9
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  lib/oauth2.js
1  lib/oauth2.js
@@ -96,6 +96,7 @@ exports.OAuth2.prototype._request= function(method, url, headers, post_body, acc
96 96 }
97 97
98 98 var request = http_library.request(options, function (response) {
  99 + response.setEncoding('utf8');
99 100 response.on("data", function (chunk) {
100 101 result+= chunk
101 102 });

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.