From 1d74d7eeab405cca13e4b48eb2c9635807a6f298 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Wed, 15 Feb 2012 13:28:17 +0100 Subject: [PATCH] Fixed a serious bug in beef.net.request when sending cross-domain POST data. jQuery is automatically changing the method to GET if the dataType (that was hardcoded in our code) is set to 'script'. --- core/main/client/net.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/main/client/net.js b/core/main/client/net.js index 9f84f5acc..b5340d472 100644 --- a/core/main/client/net.js +++ b/core/main/client/net.js @@ -168,9 +168,22 @@ beef.net = { response.was_cross_domain = cross_domain; var start_time = new Date().getTime(); + /* + * according to http://api.jquery.com/jQuery.ajax/, Note: having 'script': + * This will turn POSTs into GETs for remote-domain requests. + */ + if (method == "POST"){ + $j.ajaxSetup({ + dataType: dataType + }); + }else{ //GET, HEAD, ... + $j.ajaxSetup({ + dataType: 'script' + }); + } + //build and execute the request $j.ajax({type: method, - dataType: 'script', // this is required for bugs in IE so data can be transferred back to the server url: url, data: data, timeout: (timeout * 1000),