Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "payload=" prefix filtering on responses #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions lib/gith.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,13 @@ var listen = function( eventaur, port ) {
req.on( "end", function() {
if ( _.indexOf( gith.ips, req.connection.remoteAddress ) >= 0 ||
_.indexOf( gith.ips, "*" ) >= 0 ) {
if ( /^payload=/.test( data ) ) {
var payload = JSON.parse( querystring.unescape(data.slice(8)) );
eventaur.emit( "payload", payload );
res.writeHead( 200, {
'Content-type': 'text/html'
});
}
}

var payload = JSON.parse( querystring.unescape(data) );
eventaur.emit( "payload", payload );
res.writeHead( 200, {
'Content-type': 'text/html'
});
}
res.end();
});

Expand Down Expand Up @@ -281,11 +280,11 @@ module.exports.create = function( port ) {
};

// https://github.com/danheberden/gith/issues/13
ret.ips = [
'207.97.227.253',
'50.57.128.197',
'108.171.174.178',
'50.57.231.61'
ret.ips = [
'207.97.227.253',
'50.57.128.197',
'108.171.174.178',
'50.57.231.61'
];

// add the listen method to the function - bind to ret
Expand Down
8 changes: 3 additions & 5 deletions test/gith_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ exports['gith server'] = {
host: 'localhost',
method: 'POST'
});
request.write( 'payload=' + JSON.stringify( payloadObject ) );
request.write( JSON.stringify( payloadObject ) );
request.end();
},
'gith creates a server and listens to escaped payloads on that port': function( test ) {
Expand Down Expand Up @@ -154,7 +154,7 @@ exports['gith server'] = {
host: 'localhost',
method: 'POST'
});
request.write( 'payload=' + querystring.escape( JSON.stringify( payloadObject ) ) );
request.write( querystring.escape( JSON.stringify( payloadObject ) ) );
request.end();
}
};
Expand Down Expand Up @@ -398,7 +398,7 @@ exports['ip filtering'] = {
host: 'localhost',
method: 'POST'
});
request.write( 'payload=' + querystring.escape( JSON.stringify( json ) ) );
request.write( querystring.escape( JSON.stringify( json ) ) );
request.end();

setTimeout( function() {
Expand All @@ -407,5 +407,3 @@ exports['ip filtering'] = {
},300);
}
};