From e35148add8ce9b998113f2237da454a293c8ca88 Mon Sep 17 00:00:00 2001 From: lilia Date: Sat, 25 Oct 2014 19:48:54 -0700 Subject: [PATCH] No, jQuery, don't processData! processData (default: true) Type: Boolean By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. https://api.jquery.com/jQuery.ajax/ --- js/api.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js/api.js b/js/api.js index 3ada2f8f..2ad5aa8a 100644 --- a/js/api.js +++ b/js/api.js @@ -257,16 +257,17 @@ window.textsecure.api = function() { var id_regex = RegExp( "^https:\/\/" + ATTACHMENT_HOST + "\/(\\d+)\?"); self.putAttachment = function(encryptedBin) { return doAjax({ - call : 'attachment', - httpType : 'GET', - do_auth : true, + call : 'attachment', + httpType : 'GET', + do_auth : true, }).then(function(response) { return new Promise(function(resolve, reject) { $.ajax(response.location, { - type : "PUT", - headers : {"Content-Type" : "application/octet-stream"}, - data : encryptedBin, - success : function() { + type : "PUT", + headers : {"Content-Type" : "application/octet-stream"}, + data : encryptedBin, + processData : false, + success : function() { try { // Parse the id as a string from the location url // (workaround for ids too large for Javascript numbers)