Skip to content

fix: handle non-printable characters in browser responses#57

Closed
achingbrain wants to merge 1 commit intomasterfrom
fix/handle-non-printable-characters-in-responses
Closed

fix: handle non-printable characters in browser responses#57
achingbrain wants to merge 1 commit intomasterfrom
fix/handle-non-printable-characters-in-responses

Conversation

@achingbrain
Copy link
Member

@achingbrain achingbrain commented Aug 14, 2020

Fixes a regression introduced by #54 - in the browser by default the response body is interpreted as a string which can become corrupted when non-printable characters are encountered.

Setting the responseType param to arraybuffer makes it behave in a similar way to node.

This is currently manifesting itself as a browser test failure for ipfs as the DAG node is retrieved from the server with garbage characters in the block:

ipfs-http-client: FAILED TESTS:
ipfs-http-client:   .dag
ipfs-http-client:     ✖ should be able to put and get a DAG node with format dag-cbor
ipfs-http-client:       Chrome Headless 84.0.4147.125 (Linux x86_64)
ipfs-http-client:     Error: Undeterminated nesting
ipfs-http-client:         at Decoder._decode (file:/home/travis/build/ipfs/js-ipfs/node_modules/borc/src/decoder.js:603:15)
ipfs-http-client:         at Decoder.decodeAll (file:/home/travis/build/ipfs/js-ipfs/node_modules/borc/src/decoder.js:624:10)
ipfs-http-client:         at Object.exports.deserialize (file:/home/travis/build/ipfs/js-ipfs/node_modules/ipld-dag-cbor/src/util.js:169:23)
ipfs-http-client:         at Object.exports.resolve (file:/home/travis/build/ipfs/js-ipfs/node_modules/ipld-dag-cbor/src/resolver.js:27:19)
ipfs-http-client:         at Object.eval [as get] (file:/home/travis/build/ipfs/js-ipfs/packages/ipfs-http-client/src/dag/get.js:36:24)
ipfs-http-client:         at async Context.eval (file:/home/travis/build/ipfs/js-ipfs/packages/ipfs-http-client/test/dag.spec.js:58:20)

Fixes a regression introduced by #54 - in the browser by default the
response body is interpreted as a string which can become corrupted
when non-printable characters are encountered.
@achingbrain
Copy link
Member Author

This is a band-aid, see #54 (comment)

@jacobheun
Copy link

This is a band-aid, see #54 (comment)

We should just close this and revert the change until we can do progress updates properly then

@jacobheun
Copy link

We've decided not to do this.

@jacobheun jacobheun closed this Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants