Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4 from MarcinHoppe/fix-number-encoding
Correctly encoding values that are not strings
  • Loading branch information
jaredhanson committed May 1, 2018
2 parents a55bfd9 + d48b4dd commit 2bf9fae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/index.js
Expand Up @@ -27,7 +27,12 @@ exports = module.exports = function (txn, res, params) {
var inputs = [];

Object.keys(params).forEach(function (k) {
inputs.push(input.replace('{NAME}', k).replace('{VALUE}', entities.encode(params[k])));
var encoded = params[k];
if (typeof params[k] === 'string') {
encoded = entities.encode(params[k]);
}

inputs.push(input.replace('{NAME}', k).replace('{VALUE}', encoded));
});

res.setHeader('Content-Type', 'text/html;charset=UTF-8');
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "oauth2orize-fprm",
"version": "0.2.0",
"version": "0.2.1",
"description": "Form Post response mode support for OAuth2orize.",
"keywords": [
"oauth2",
Expand Down
4 changes: 3 additions & 1 deletion test/package.test.js
Expand Up @@ -74,7 +74,8 @@ nrQ5IKXuNsQ1g9ccT5DMtZSwgDFwsHMDWMPFGax5Lw6ogjwJ4AQDrhzNCFc\
scope: '"></a>openid email user_metadata',
response_mode: '"></a>form_post',
state: req.oauth2.req.state,
id_token: '"></a>eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzdWIiOiJqb2huIiw'
id_token: '"></a>eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzdWIiOiJqb2huIiw',
expires_in: 86400
};

fprm(req.oauth2, res, params);
Expand All @@ -100,6 +101,7 @@ nrQ5IKXuNsQ1g9ccT5DMtZSwgDFwsHMDWMPFGax5Lw6ogjwJ4AQDrhzNCFc\
<input type="hidden" name="response_mode" value="&quot;&gt;&lt;/a&gt;form_post"/>\
<input type="hidden" name="state" value="&quot;&gt;&lt;/a&gt;DcP7csa3hMlvybERqcieLHrRzKBra"/>\
<input type="hidden" name="id_token" value="&quot;&gt;&lt;/a&gt;eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzdWIiOiJqb2huIiw"/>\
<input type="hidden" name="expires_in" value="86400"/>\
</form></body></html>');
});
});
Expand Down

0 comments on commit 2bf9fae

Please sign in to comment.