instanceof failing in window / iframe contexts#350
Merged
dduponchel merged 3 commits intoStuk:masterfrom Sep 5, 2016
Merged
Conversation
instanceof fails with data passed in from other contexts
instanceof failing in window / iframe contexts
| // if inputData is already a promise, this flatten it. | ||
| var promise = external.Promise.resolve(inputData).then(function(data) { | ||
|
|
||
| var isBlob = data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) != -1; |
Contributor
There was a problem hiding this comment.
Could you use !== instead of != ?
Contributor
|
I think you forgot to actually use |
Contributor
Author
|
Wow. Well that was dumb ;) Upped |
dduponchel
added a commit
to dduponchel/jszip
that referenced
this pull request
Sep 28, 2016
The pull request Stuk#350 introduced a bug but the automated tests didn't catch it: > ReferenceError: Blob is not defined > at /home/travis/build/Stuk/jszip/lib/utils.js:425:38 > at Array.1 (/home/travis/build/Stuk/jszip/node_modules/lie/lib/index.js:88:21) > at nextTick (/home/travis/build/Stuk/jszip/node_modules/lie/node_modules/immediate/lib/index.js:61:18) > at process._tickCallback (node.js:458:13) > > The command "npm run $COMMAND" exited with 0. > > Done. Your build exited with 0. This commit fixes: - the bug: check if Blobs are supported before actually using them - the build: if an uncaught error/rejection happens, exit with a non zero code.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prepareContentfails to properly derive type of data passed in, should the Blob originate from another context (window or iframe).Described here from MDN (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof)
Proposal is to first check
instanceof(much faster), with a backup check againstObject.prototype.toStringwhich is safe across contexts (http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/)