From fe74a1d7eda442cf9d529bd26ecdefe88e182a7c Mon Sep 17 00:00:00 2001 From: Simon Woolf Date: Thu, 14 May 2015 11:29:46 +0100 Subject: [PATCH] Regenerated --- browser/static/ably.js | 25 +++++++++++++++++++------ browser/static/ably.noencryption.js | 25 +++++++++++++++++++------ browser/static/compat-pusher.js | 5 +++++ browser/static/iframe-0.8.0.html | 5 +++++ browser/static/iframe.js | 5 +++++ 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/browser/static/ably.js b/browser/static/ably.js index 0a08cc5d67..c372f457be 100644 --- a/browser/static/ably.js +++ b/browser/static/ably.js @@ -2505,8 +2505,8 @@ var BufferUtils = (function() { var ArrayBuffer = window.ArrayBuffer; var TextDecoder = window.TextDecoder; - function isWordArray(ob) { return ob.sigBytes !== undefined; } - function isArrayBuffer(ob) { return ob.constructor === ArrayBuffer; } + function isWordArray(ob) { return ob !== null && ob !== undefined && ob.sigBytes !== undefined; } + function isArrayBuffer(ob) { return ob !== null && ob !== undefined && ob.constructor === ArrayBuffer; } // https://gist.githubusercontent.com/jonleighton/958841/raw/f200e30dfe95212c0165ccf1ae000ca51e9de803/gistfile1.js function arrayBufferToBase64(ArrayBuffer) { @@ -2626,6 +2626,7 @@ var BufferUtils = (function() { return BufferUtils; })(); + var Cookie = (function() { var isBrowser = (typeof(window) == 'object'); function noop() {} @@ -4143,6 +4144,11 @@ var Utils = (function() { return Object.prototype.toString.call(ob) == '[object Array]'; }; + /* ...Or an Object (in the narrow sense) */ + Utils.isObject = function(ob) { + return Object.prototype.toString.call(ob) == '[object Object]'; + }; + /* * Determine whether or not an object contains * any enumerable properties. @@ -4477,11 +4483,18 @@ var Message = (function() { }; Message.encode = function(msg, options) { - var data = msg.data, encoding; - if(data !== null && data !== undefined && typeof(data) != 'string' && !BufferUtils.isBuffer(data)) { - msg.data = JSON.stringify(data); - msg.encoding = (encoding = msg.encoding) ? (encoding + '/json') : 'json'; + var data = msg.data, encoding, + nativeDataType = typeof(data) == 'string' || BufferUtils.isBuffer(data) || data === null || data === undefined; + + if (!nativeDataType) { + if (Utils.isObject(data) || Utils.isArray(data)) { + msg.data = JSON.stringify(data); + msg.encoding = (encoding = msg.encoding) ? (encoding + '/json') : 'json'; + } else { + throw new ErrorInfo('Data type is unsupported', 40011, 400); + } } + if(options != null && options.encrypted) Message.encrypt(msg, options); }; diff --git a/browser/static/ably.noencryption.js b/browser/static/ably.noencryption.js index 9c63691fb9..0534c92b77 100644 --- a/browser/static/ably.noencryption.js +++ b/browser/static/ably.noencryption.js @@ -1157,8 +1157,8 @@ var BufferUtils = (function() { var ArrayBuffer = window.ArrayBuffer; var TextDecoder = window.TextDecoder; - function isWordArray(ob) { return ob.sigBytes !== undefined; } - function isArrayBuffer(ob) { return ob.constructor === ArrayBuffer; } + function isWordArray(ob) { return ob !== null && ob !== undefined && ob.sigBytes !== undefined; } + function isArrayBuffer(ob) { return ob !== null && ob !== undefined && ob.constructor === ArrayBuffer; } // https://gist.githubusercontent.com/jonleighton/958841/raw/f200e30dfe95212c0165ccf1ae000ca51e9de803/gistfile1.js function arrayBufferToBase64(ArrayBuffer) { @@ -1278,6 +1278,7 @@ var BufferUtils = (function() { return BufferUtils; })(); + var Cookie = (function() { var isBrowser = (typeof(window) == 'object'); function noop() {} @@ -2795,6 +2796,11 @@ var Utils = (function() { return Object.prototype.toString.call(ob) == '[object Array]'; }; + /* ...Or an Object (in the narrow sense) */ + Utils.isObject = function(ob) { + return Object.prototype.toString.call(ob) == '[object Object]'; + }; + /* * Determine whether or not an object contains * any enumerable properties. @@ -3129,11 +3135,18 @@ var Message = (function() { }; Message.encode = function(msg, options) { - var data = msg.data, encoding; - if(data !== null && data !== undefined && typeof(data) != 'string' && !BufferUtils.isBuffer(data)) { - msg.data = JSON.stringify(data); - msg.encoding = (encoding = msg.encoding) ? (encoding + '/json') : 'json'; + var data = msg.data, encoding, + nativeDataType = typeof(data) == 'string' || BufferUtils.isBuffer(data) || data === null || data === undefined; + + if (!nativeDataType) { + if (Utils.isObject(data) || Utils.isArray(data)) { + msg.data = JSON.stringify(data); + msg.encoding = (encoding = msg.encoding) ? (encoding + '/json') : 'json'; + } else { + throw new ErrorInfo('Data type is unsupported', 40011, 400); + } } + if(options != null && options.encrypted) Message.encrypt(msg, options); }; diff --git a/browser/static/compat-pusher.js b/browser/static/compat-pusher.js index 274ccb984c..4aef7835a1 100644 --- a/browser/static/compat-pusher.js +++ b/browser/static/compat-pusher.js @@ -189,6 +189,11 @@ var Utils = (function() { return Object.prototype.toString.call(ob) == '[object Array]'; }; + /* ...Or an Object (in the narrow sense) */ + Utils.isObject = function(ob) { + return Object.prototype.toString.call(ob) == '[object Object]'; + }; + /* * Determine whether or not an object contains * any enumerable properties. diff --git a/browser/static/iframe-0.8.0.html b/browser/static/iframe-0.8.0.html index 6a95a346f8..28900a9e8e 100644 --- a/browser/static/iframe-0.8.0.html +++ b/browser/static/iframe-0.8.0.html @@ -359,6 +359,11 @@ return Object.prototype.toString.call(ob) == '[object Array]'; }; + /* ...Or an Object (in the narrow sense) */ + Utils.isObject = function(ob) { + return Object.prototype.toString.call(ob) == '[object Object]'; + }; + /* * Determine whether or not an object contains * any enumerable properties. diff --git a/browser/static/iframe.js b/browser/static/iframe.js index c75c8a21ea..0f19511811 100644 --- a/browser/static/iframe.js +++ b/browser/static/iframe.js @@ -354,6 +354,11 @@ var Utils = (function() { return Object.prototype.toString.call(ob) == '[object Array]'; }; + /* ...Or an Object (in the narrow sense) */ + Utils.isObject = function(ob) { + return Object.prototype.toString.call(ob) == '[object Object]'; + }; + /* * Determine whether or not an object contains * any enumerable properties.