Skip to content

Commit 6274d60

Browse files
author
Devendra
committed
adding fixes for allowing publish and receive of 0, null, "null", "0"
1 parent a0aba9b commit 6274d60

27 files changed

Lines changed: 144 additions & 104 deletions

File tree

core/crypto/encrypt-pubnub.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PUBNUB['secure'] = (function(){
2222
return plaintext;
2323
}
2424
catch (e) {
25-
return null;
25+
return undefined;
2626
}
2727
}
2828

@@ -54,7 +54,7 @@ PUBNUB['secure'] = (function(){
5454
latency
5555
) {
5656
var decrypted = decrypt(message);
57-
if(decrypted) {
57+
if(typeof(decrypted) !== "undefined") {
5858
callback(decrypted, envelope, channel, latency);
5959
} else {
6060
args.error && args.error({"error":"DECRYPT_ERROR", "message" : message});

core/pubnub-common.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ function uuid(callback) {
125125
if (callback) callback(u);
126126
return u;
127127
}
128+
function isArray(arg) {
129+
return Object.prototype.toString.call(arg) === "[object Array]";
130+
}
128131

129132
/**
130133
* EACH
@@ -134,7 +137,7 @@ function uuid(callback) {
134137
function each( o, f ) {
135138
if ( !o || !f ) return;
136139

137-
if ( typeof o[0] != 'undefined' )
140+
if ( isArray(o) )
138141
for ( var i = 0, l = o.length; i < l; )
139142
f.call( o[i], o[i], i++ );
140143
else
@@ -443,7 +446,7 @@ function PN_API(setup) {
443446

444447
if (args['prepend']) add_msg = 'unshift'
445448

446-
if (!msg) return error_common('Missing Message', err);
449+
if(typeof(msg) === "undefined") return error_common('Missing Message', err);
447450
if (!channel) return error_common('Missing Channel', err);
448451
if (!PUBLISH_KEY) return error_common('Missing Publish Key', err);
449452
if (!SUBSCRIBE_KEY) return error_common('Missing Subscribe Key', err);

modern/pubnub-crypto.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modern/pubnub.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ function uuid(callback) {
126126
if (callback) callback(u);
127127
return u;
128128
}
129+
function isArray(arg) {
130+
return Object.prototype.toString.call(arg) === "[object Array]";
131+
}
129132

130133
/**
131134
* EACH
@@ -135,7 +138,7 @@ function uuid(callback) {
135138
function each( o, f ) {
136139
if ( !o || !f ) return;
137140

138-
if ( typeof o[0] != 'undefined' )
141+
if ( isArray(o) )
139142
for ( var i = 0, l = o.length; i < l; )
140143
f.call( o[i], o[i], i++ );
141144
else
@@ -444,7 +447,7 @@ function PN_API(setup) {
444447

445448
if (args['prepend']) add_msg = 'unshift'
446449

447-
if (!msg) return error_common('Missing Message', err);
450+
if(typeof(msg) === "undefined") return error_common('Missing Message', err);
448451
if (!channel) return error_common('Missing Channel', err);
449452
if (!PUBLISH_KEY) return error_common('Missing Publish Key', err);
450453
if (!SUBSCRIBE_KEY) return error_common('Missing Subscribe Key', err);

modern/pubnub.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node.js/pubnub.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ function uuid(callback) {
126126
if (callback) callback(u);
127127
return u;
128128
}
129+
function isArray(arg) {
130+
return Object.prototype.toString.call(arg) === "[object Array]";
131+
}
129132

130133
/**
131134
* EACH
@@ -135,7 +138,7 @@ function uuid(callback) {
135138
function each( o, f ) {
136139
if ( !o || !f ) return;
137140

138-
if ( typeof o[0] != 'undefined' )
141+
if ( isArray(o) )
139142
for ( var i = 0, l = o.length; i < l; )
140143
f.call( o[i], o[i], i++ );
141144
else
@@ -444,7 +447,7 @@ function PN_API(setup) {
444447

445448
if (args['prepend']) add_msg = 'unshift'
446449

447-
if (!msg) return error_common('Missing Message', err);
450+
if(typeof(msg) === "undefined") return error_common('Missing Message', err);
448451
if (!channel) return error_common('Missing Channel', err);
449452
if (!PUBLISH_KEY) return error_common('Missing Publish Key', err);
450453
if (!SUBSCRIBE_KEY) return error_common('Missing Subscribe Key', err);

0 commit comments

Comments
 (0)