Skip to content
Browse files

Handle undefined parameter object and return false

  • Loading branch information...
1 parent 026d4a0 commit 970824d623226e9a60849ef4125beda67cc5073a @TauZero TauZero committed Feb 21, 2012
Showing with 10 additions and 2 deletions.
  1. +1 −0 lib/sailthru.js
  2. +2 −0 src/sailthru.coffee
  3. +7 −2 test/test_sailthru.coffee
View
1 lib/sailthru.js
@@ -529,6 +529,7 @@
SailthruClient.prototype.receiveOptoutPost = function(params) {
var param, sig, _i, _len, _ref2;
+ if (typeof params === 'undefined') return false;
_ref2 = ['action', 'email', 'sig'];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
param = _ref2[_i];
View
2 src/sailthru.coffee
@@ -379,6 +379,8 @@ class SailthruClient
# Postback API Methods
receiveOptoutPost: (params) ->
+ if typeof params is 'undefined'
+ return false
for param in ['action','email','sig']
if typeof params[param] is 'undefined'
return false
View
9 test/test_sailthru.coffee
@@ -2,7 +2,7 @@ SailthruClient = require('../lib/sailthru').createSailthruClient('abcd12345','1
{testCase} = require 'nodeunit'
exports.receiveOptoutPost = (test) ->
- test.expect 6
+ test.expect 7
# Valid params
params1 =
@@ -47,7 +47,12 @@ exports.receiveOptoutPost = (test) ->
email: 'foo@bar.com'
sig: '110993c3e8786cb4ebdd509ea6115fea'
real6 = SailthruClient.receiveOptoutPost params6
- test.ok not real5
+ test.ok not real6
+
+ # No Params
+ params7 = undefined
+ real7 = SailthruClient.receiveOptoutPost params7
+ test.ok not real7
test.done()

0 comments on commit 970824d

Please sign in to comment.
Something went wrong with that request. Please try again.