graphql-upload 18.0.1 → 18.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/processRequest.mjs +31 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-upload",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.2",
|
|
4
4
|
"description": "Middleware and a scalar Upload to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
package/processRequest.mjs
CHANGED
|
@@ -202,6 +202,34 @@ export default function processRequest(
|
|
|
202
202
|
);
|
|
203
203
|
|
|
204
204
|
try {
|
|
205
|
+
// Check the upload’s mapped path in the operations is safe
|
|
206
|
+
// before setting it.
|
|
207
|
+
|
|
208
|
+
const keys = path.split(".");
|
|
209
|
+
|
|
210
|
+
/** @type {unknown} */
|
|
211
|
+
let pathValue = operations;
|
|
212
|
+
|
|
213
|
+
for (const [keyIndex, key] of keys.entries()) {
|
|
214
|
+
// Forbid `__proto__` keys to prevent prototype manipulation
|
|
215
|
+
// that could make client-supplied objects pass
|
|
216
|
+
// `instanceof Upload` checks.
|
|
217
|
+
if (key === "__proto__")
|
|
218
|
+
throw new TypeError("Object path has a `__proto__` key.");
|
|
219
|
+
|
|
220
|
+
// Forbid setting an upload within an already set upload, but
|
|
221
|
+
// allow a total replacement.
|
|
222
|
+
if (keyIndex < keys.length - 1) {
|
|
223
|
+
pathValue = objectPath.get(
|
|
224
|
+
/** @type {object} */ (pathValue),
|
|
225
|
+
[key],
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (pathValue instanceof Upload)
|
|
229
|
+
throw new TypeError("Object path traverses an upload.");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
205
233
|
operationsPath.set(path, map.get(fieldName));
|
|
206
234
|
} catch {
|
|
207
235
|
return exit(
|
|
@@ -234,9 +262,9 @@ export default function processRequest(
|
|
|
234
262
|
|
|
235
263
|
const upload = map.get(fieldName);
|
|
236
264
|
|
|
237
|
-
if (!upload) {
|
|
238
|
-
// The file is extraneous. As the rest can still be
|
|
239
|
-
// ignore it and don’t exit with an error.
|
|
265
|
+
if (!upload || upload.file) {
|
|
266
|
+
// The file is extraneous or a duplicate. As the rest can still be
|
|
267
|
+
// processed, just ignore it and don’t exit with an error.
|
|
240
268
|
ignoreStream(stream);
|
|
241
269
|
return;
|
|
242
270
|
}
|