Skip to content

Commit 6b8d601

Browse files
author
Levi Cameron
committed
Fix boundary detection regex not handling spaces inside boundary marker correctly
1 parent 1c44ef2 commit 6b8d601

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rest_framework/static/rest_framework/js/ajax-form.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function doAjaxSubmit(e) {
4242
// We need to add a boundary parameter to the header
4343
// We assume the first valid-looking boundary line in the body is correct
4444
// regex is from RFC 2046 appendix A
45-
var re = /^--([0-9A-Z'()+_,-./:=?]{1,70})[ \f\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*$/im;
45+
var boundaryCharNoSpace = "[0-9A-Z'()+_,-./:=?";
46+
var boundaryChar = boundaryCharNoSpace + ' ';
47+
var re = new RegExp('^--([' + boundaryChar + ']{0,69}[' + boundaryCharNoSpace + '])[\\s]*?$', 'im');
4648
var boundary = data.match(re);
4749
if (boundary !== null) {
4850
contentType += '; boundary="' + boundary[1] + '"';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy