From 1c44ef2b11f42b28af188b6ac60a91c95102391f Mon Sep 17 00:00:00 2001 From: Levi Cameron Date: Tue, 30 May 2017 10:43:33 +1000 Subject: [PATCH] Improvements to code clarity --- rest_framework/static/rest_framework/js/ajax-form.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework/static/rest_framework/js/ajax-form.js b/rest_framework/static/rest_framework/js/ajax-form.js index 88cb133bf..cb41343ee 100644 --- a/rest_framework/static/rest_framework/js/ajax-form.js +++ b/rest_framework/static/rest_framework/js/ajax-form.js @@ -40,8 +40,10 @@ function doAjaxSubmit(e) { if (contentType === 'multipart/form-data') { // We need to add a boundary parameter to the header + // We assume the first valid-looking boundary line in the body is correct + // regex is from RFC 2046 appendix A var re = /^--([0-9A-Z'()+_,-./:=?]{1,70})[ \f\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*$/im; - var boundary = re.exec(data); + var boundary = data.match(re); if (boundary !== null) { contentType += '; boundary="' + boundary[1] + '"'; }