From 7598abbf297216940cb433b3e1da54214ef153ef Mon Sep 17 00:00:00 2001 From: SautdeChat Date: Fri, 6 Feb 2015 11:46:04 +0100 Subject: [PATCH] Added support for FormData objects in new_send() --- js/csrfprotector.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/csrfprotector.js b/js/csrfprotector.js index 8a09943..6f37913 100644 --- a/js/csrfprotector.js +++ b/js/csrfprotector.js @@ -247,13 +247,16 @@ function csrfprotector_init() { */ function new_send(data) { if (this.method.toLowerCase() === 'post') { - if (data !== "") { - data += "&"; + if (data !== null && typeof data === 'object') { + data.append(CSRFP.CSRFP_TOKEN, CSRFP._getAuthKey()); } else { - data = ""; + if (data !== "") { + data += "&"; + } else { + data = ""; + } + data += CSRFP.CSRFP_TOKEN +"=" +CSRFP._getAuthKey(); } - - data += CSRFP.CSRFP_TOKEN +"=" +CSRFP._getAuthKey(); } return this.old_send(data); } @@ -310,4 +313,4 @@ function csrfprotector_init() { }); } -} \ No newline at end of file +}