Skip to content

Commit

Permalink
Fix boundary detection regex not handling spaces inside boundary mark…
Browse files Browse the repository at this point in the history
…er correctly
  • Loading branch information
Levi Cameron committed May 31, 2017
1 parent 1c44ef2 commit 6b8d601
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rest_framework/static/rest_framework/js/ajax-form.js
Expand Up @@ -42,7 +42,9 @@ function doAjaxSubmit(e) {
// 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 boundaryCharNoSpace = "[0-9A-Z'()+_,-./:=?";
var boundaryChar = boundaryCharNoSpace + ' ';
var re = new RegExp('^--([' + boundaryChar + ']{0,69}[' + boundaryCharNoSpace + '])[\\s]*?$', 'im');
var boundary = data.match(re);
if (boundary !== null) {
contentType += '; boundary="' + boundary[1] + '"';
Expand Down

0 comments on commit 6b8d601

Please sign in to comment.