From: Alexander Ebert Date: Sun, 24 May 2015 16:41:44 +0000 (+0200) Subject: Rejecting response if content-type mismatches in WoltLab/WCF/Ajax/Request X-Git-Tag: 3.0.0_Beta_1~2316 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4a179dfad982decf354abd83d5ff8e36527ecced;p=GitHub%2FWoltLab%2FWCF.git Rejecting response if content-type mismatches in WoltLab/WCF/Ajax/Request --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js index aa5c0b37a0..78039062d4 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js @@ -22,6 +22,7 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt this._options = Core.extend({ // request data data: {}, + responseType: 'application/json', type: 'POST', url: '', @@ -87,7 +88,13 @@ define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'Wolt this._xhr.onload = function() { if (this.readyState === XMLHttpRequest.DONE) { if (this.status >= 200 && this.status < 300 || this.status === 304) { - self._success(this, options); + if (options.responseType && options.responseType !== this.getResponseHeader('Content-Type')) { + // request succeeded but invalid response type + self._failure(this, options); + } + else { + self._success(this, options); + } } else { self._failure(this, options);