Skip to content

Commit 8ff849c

Browse files
author
Erick Calder
committed
Proper header production
the existing code uses a for loop to iterate through headers but does not check that the values are actually properties, therefore it picks up methods. these methods can appear as they are defined within the Object.prototype and including them in the headers breaks requests as the stringified methods likely contain carriage returns, which breaks the request due to malformation of the header in general, it is better to use Object.keys(headers).forEach() but I didn’t want to change the style of the code so a call to .hasOwnProperty() solves the problem
1 parent 3eabb17 commit 8ff849c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

lib/form_data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ FormData.prototype._multiPartHeader = function(field, value, options) {
186186

187187
var header;
188188
for (var prop in headers) {
189+
if (!headers.hasOwnProperty(prop)) continue;
189190
header = headers[prop];
190191

191192
// skip nullish headers.

0 commit comments

Comments
 (0)