diff options
author | Ruben Rodriguez <ruben@gnu.org> | 2015-07-13 22:53:44 -0500 |
---|---|---|
committer | Ruben Rodriguez <ruben@gnu.org> | 2015-07-13 22:53:44 -0500 |
commit | 240c29c1d9cf6a2adfad8692917d60cde071cce3 (patch) | |
tree | 437c262a88e805a9dd3d381e0e46b77bd286b1eb /data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer | |
parent | 23103d7773e24fdf15b79ed69c67089b593fb31a (diff) |
LibreJS updated to 6.0.9
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer')
2 files changed, 61 insertions, 25 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/process_response.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/process_response.js index c1f5e88..924636b 100644 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/process_response.js +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/process_response.js @@ -81,17 +81,6 @@ var processResponseObject = { }, /** - * genBinaryOutput - * Set or reset binaryOutputStream and storageStream. - */ - genBinaryOutput: function () { - this.storageStream = Cc["@mozilla.org/storagestream;1"] - .createInstance(Ci.nsIStorageStream); - this.binaryOutputStream = Cc["@mozilla.org/binaryoutputstream;1"] - .createInstance(Ci.nsIBinaryOutputStream); - }, - - /** * Gather the data gathered from onDataAvailable. */ setData: function () { @@ -203,7 +192,6 @@ var processResponseObject = { processJS: function() { var checker, check, jsCheckString, that = this; - //var start = Date.now(), end; try { // make sure script isn't already listed as free @@ -212,7 +200,6 @@ var processResponseObject = { // this is free. we are done. this.jsListenerCallback(); return; - } // analyze javascript in response. @@ -222,8 +209,6 @@ var processResponseObject = { that.processJsCallback(checker); }, that.url); - - } catch(e) { // any error is considered nontrivial. @@ -273,7 +258,6 @@ var processResponseObject = { return true; } - } } }, @@ -393,21 +377,26 @@ var processResponseObject = { jsListenerCallback: function () { - var len = this.data.length; + var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] + .createInstance(Ci.nsIScriptableUnicodeConverter); - this.genBinaryOutput(); + if (typeof this.req.contentCharset !== 'undefined' && + this.req.contentCharset !== '' && + this.req.contentCharset !== null + ) { + converter.charset = this.req.contentCharset; + } else { + converter.charset = "UTF-8"; + } - this.storageStream.init(8192, len, null); - this.binaryOutputStream.setOutputStream( - this.storageStream.getOutputStream(0)); - this.binaryOutputStream.writeBytes(this.data, len); + var stream = converter.convertToInputStream(this.data); try { this.listener.onDataAvailable( this.req, this.resInfo.context, - this.storageStream.newInputStream(0), - 0, len); + stream, + 0, stream.available()); } catch (e) { this.req.cancel(this.req.NS_BINDING_ABORTED); } diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/stream_loader.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/stream_loader.js index 42187c8..ec21cb7 100644 --- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/stream_loader.js +++ b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/resources/librejs/lib/http_observer/stream_loader.js @@ -22,6 +22,49 @@ var {Cc, Ci, Cu, Cm, Cr} = require("chrome"); const processResponse = require('http_observer/process_response'); +const CHARSETS = [ + '866', 'ansi_x3.4-1968', 'arabic', 'ascii', 'asmo-708', 'big5', + 'big5-hkscs', 'chinese', 'cn-big5', 'cp1250', 'cp1251', 'cp1252', + 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', + 'cp819', 'cp866', 'csbig5', 'cseuckr', 'cseucpkdfmtjapanese', + 'csgb2312', 'csibm866', 'csiso2022jp', 'csiso2022kr', 'csiso58gb231280', + 'csiso88596e', 'csiso88596i', 'csiso88598e', 'csiso88598i', 'csisolatin1', + 'csisolatin2', 'csisolatin3', 'csisolatin4', 'csisolatin5', 'csisolatin6', + 'csisolatin9', 'csisolatinarabic', 'csisolatincyrillic', + 'csisolatingreek', 'csisolatinhebrew', 'cskoi8r', 'csksc56011987', + 'csmacintosh', 'csshiftjis', 'cyrillic', 'dos-874', 'ecma-114', + 'ecma-118', 'elot_928', 'euc-jp', 'euc-kr', 'gb18030', 'gb2312', + 'gb_2312', 'gb_2312-80', 'gbk', 'greek', 'greek8', 'hebrew', + 'hz-gb-2312', 'ibm819', 'ibm866', 'iso-2022-cn', 'iso-2022-cn-ext', + 'iso-2022-jp', 'iso-2022-kr', 'iso88591', 'iso_8859-1', 'iso-8859-1', + 'iso8859-1', 'iso885910', 'iso-8859-10', 'iso8859-10', 'iso885911', + 'iso-8859-11', 'iso8859-11', 'iso_8859-1:1987', 'iso885913', 'iso-8859-13', + 'iso8859-13', 'iso885914', 'iso-8859-14', 'iso8859-14', 'iso885915', + 'iso-8859-15', 'iso8859-15', 'iso-8859-16', 'iso88592', 'iso_8859-2', + 'iso-8859-2', 'iso8859-2', 'iso_8859-2:1987', 'iso88593', 'iso_8859-3', + 'iso-8859-3', 'iso8859-3', 'iso_8859-3:1988', 'iso88594', 'iso_8859-4', + 'iso-8859-4', 'iso8859-4', 'iso_8859-4:1988', 'iso88595', 'iso_8859-5', + 'iso-8859-5', 'iso_8859-5:1988', 'iso88596', 'iso_8859-6', 'iso-8859-6', + 'iso8859-6', 'iso_8859-6:1987', 'iso-8859-6-e', 'iso-8859-6-i', 'iso88597', + 'iso_8859-7', 'iso-8859-7', 'iso8859-7', 'iso_8859-7:1987', 'iso88598', + 'iso_8859-8', 'iso-8859-8', 'iso8859-8', 'iso_8859-8:1988', 'iso-8859-8-e', + 'iso-8859-8i', 'iso-8859-8-i', 'iso88599', 'iso_8859-9', 'iso-8859-9', + 'iso8859-9', 'iso_8859-9:1989', 'iso-ir-100', 'iso-ir-101', 'iso-ir-109', + 'iso-ir-110', 'iso-ir-126', 'iso-ir-127', 'iso-ir-138', 'iso-ir-144', + 'iso-ir-148', 'iso-ir-149', 'iso-ir-157', 'iso-ir-58', 'koi', 'koi8', + 'koi8_r', 'koi8-r', 'koi8-u', 'korean', 'ksc5601', 'ksc_5601', + 'ks_c_5601-1987', 'ks_c_5601-1989', 'l1', 'l2', 'l3', 'l4', 'l5', 'l6', + 'l9', 'latin1', 'latin2', 'latin3', 'latin4', 'latin5', 'latin6', 'latin9', + 'logical', 'mac', 'macintosh', 'ms_kanji', 'replacement', 'shift_jis', + 'shift-jis', 'sjis', 'sun_eu_greek', 'tis-620', 'unicode-1-1-utf-8', + 'us-ascii', 'utf-16', 'utf-16be', 'utf-16le', 'utf8', 'utf-8', 'visual', + 'windows-1250', 'windows-1251', 'windows-1252', 'windows-1253', + 'windows-1254', 'windows-1255', 'windows-1256', 'windows-1257', + 'windows-1258', 'windows-31j', 'windows-874', 'windows-949', 'x-cp1250', + 'x-cp1251', 'x-cp1252', 'x-cp1253', 'x-cp1254', 'x-cp1255', 'x-cp1256', + 'x-cp1257', 'x-cp1258', 'x-euc-jp', 'x-gbk', 'x-mac-cyrillic', + 'x-mac-roman', 'x-mac-ukrainian', 'x-sjis', 'x-user-defined', 'x-x-big5' +]; var StreamLoader = function() { this.loader = null; @@ -97,7 +140,11 @@ StreamListener.prototype.onDetermineCharset = function onDetermineCharset( return loader.channel.contentCharset; } else { match = getRegexForContentType(loader.channel.contentType).exec(data); - if (match) { + if (typeof match !== 'undefined' && + match !== null && + match.length > 0 && + CHARSETS.indexOf(match[1].toLowerCase()) >= 0 + ) { loader.channel.contentCharset = match[1]; return match[1]; } else { |