www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 9220b2d9c2270a91cedc59d7dd52894ddffe1134
parent 7271fdf6b72d78329273229f9602806ad7b13b78
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sat,  5 May 2018 00:09:35 -0400

Fix inconsequential bug in Zotero.MIME.sniffForMIMEType()

`undefined` was being passed as an argument to slice(), but 0 is the
only offset that's used anyway, and that's what happens if you pass
`undefined`.

Diffstat:
Mchrome/content/zotero/xpcom/mime.js | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js @@ -26,7 +26,6 @@ Zotero.MIME = new function(){ this.isTextType = isTextType; this.getPrimaryExtension = getPrimaryExtension; - this.sniffForMIMEType = sniffForMIMEType; this.sniffForBinary = sniffForBinary; this.hasNativeHandler = hasNativeHandler; this.hasInternalHandler = hasInternalHandler; @@ -228,12 +227,12 @@ Zotero.MIME = new function(){ /* * Searches string for magic numbers */ - function sniffForMIMEType(str){ - for (var i in _snifferEntries){ - var match = false; + this.sniffForMIMEType = function (str) { + for (let i in _snifferEntries) { + let match = false; // If an offset is defined, match only from there - if (typeof _snifferEntries[i][2] != 'undefined') { - if (str.substr(i[2]).indexOf(_snifferEntries[i][0]) == 0) { + if (_snifferEntries[i][2] != undefined) { + if (str.substr(_snifferEntries[i][2]).indexOf(_snifferEntries[i][0]) == 0) { match = true; } } @@ -274,7 +273,7 @@ Zotero.MIME = new function(){ * ext is an optional file extension hint if data sniffing is unsuccessful */ this.getMIMETypeFromData = function (str, ext){ - var mimeType = sniffForMIMEType(str); + var mimeType = this.sniffForMIMEType(str); if (mimeType){ Zotero.debug('Detected MIME type ' + mimeType); return mimeType;