Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Support for JSON api which use json-vulnerability protrection #124

Open
Remco75 opened this issue Oct 12, 2016 · 0 comments
Open

Support for JSON api which use json-vulnerability protrection #124

Remco75 opened this issue Oct 12, 2016 · 0 comments

Comments

@Remco75
Copy link
Contributor

Remco75 commented Oct 12, 2016

One for the list:
I have endpoints that use JSON-vulnerability protection. That means it adds )]}, before the start of the response-json, making it invalid. (this protection is widely used, among others, angular supports parsing these responses).

When encountered with this response node doesn't view this as JSON, but just returnes the string.
This might actually be the behaviour noticed in #94 :-)

I did not find a way to solve this with request-options, so we probably would need to parse the string.
(if anyone knows of a way to solve this with request: plz comment)

I see to other ways to solve this:

  1. add a config options: useJSONvulnerability (or something shorter ;-)) and then do this in the response-handler:
function(error, res, body) {
        if (error) return done(error);
        body = JSON.parse(body.substring(5));
        // test your stuff
}
  1. Assume what's reasonable: If using JSON-request, simply check if typeof body === 'string' and then do the above.

Please share your thoughts on this, I will do this right after test-refactoring

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant