File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -100,21 +100,31 @@ exports.disposition = function (header) {
100
100
throw Boom . badRequest ( 'Invalid content-disposition header format includes invalid parameters' ) ;
101
101
}
102
102
103
+ let value ;
104
+
103
105
if ( $2 ) {
104
106
if ( ! $3 ) {
105
107
throw Boom . badRequest ( 'Invalid content-disposition header format includes invalid parameters' ) ;
106
108
}
107
109
108
110
try {
109
- result [ $1 ] = decodeURIComponent ( $3 . split ( '\'' ) [ 2 ] ) ;
111
+ value = decodeURIComponent ( $3 . split ( '\'' ) [ 2 ] ) ;
110
112
}
111
113
catch ( err ) {
112
114
throw Boom . badRequest ( 'Invalid content-disposition header format includes invalid parameters' ) ;
113
115
}
114
116
}
115
117
else {
116
- result [ $1 ] = $4 || $5 || '' ;
118
+ value = $4 || $5 || '' ;
119
+ }
120
+
121
+ if ( $1 === 'name' &&
122
+ value === '__proto__' ) {
123
+
124
+ throw Boom . badRequest ( 'Invalid content-disposition header format includes invalid parameters' ) ;
117
125
}
126
+
127
+ result [ $1 ] = value ;
118
128
} ) ;
119
129
120
130
if ( ! result . name ) {
Original file line number Diff line number Diff line change @@ -169,4 +169,10 @@ describe('disposition()', () => {
169
169
const header = 'form-data; name="file"; filename=file.jpg; __proto__=x' ;
170
170
expect ( ( ) => Content . disposition ( header ) ) . to . throw ( 'Invalid content-disposition header format includes invalid parameters' ) ;
171
171
} ) ;
172
+
173
+ it ( 'errors on __proto__ name param value' , ( ) => {
174
+
175
+ const header = 'form-data; name="__proto__"; filename=file.jpg' ;
176
+ expect ( ( ) => Content . disposition ( header ) ) . to . throw ( 'Invalid content-disposition header format includes invalid parameters' ) ;
177
+ } ) ;
172
178
} ) ;
You can’t perform that action at this time.
0 commit comments