@sveltejs/kit 2.53.2 → 2.53.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "2.53.2",
3
+ "version": "2.53.3",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -39,8 +39,8 @@
39
39
  "@types/node": "^18.19.119",
40
40
  "@types/set-cookie-parser": "^2.4.7",
41
41
  "dts-buddy": "^0.7.0",
42
- "rollup": "^4.14.2",
43
- "svelte": "^5.51.5",
42
+ "rollup": "^4.59.0",
43
+ "svelte": "^5.53.5",
44
44
  "svelte-preprocess": "^6.0.0",
45
45
  "typescript": "^5.3.3",
46
46
  "vite": "^6.3.5",
@@ -245,7 +245,7 @@ export async function deserialize_binary_form(request) {
245
245
  const data_buffer = await get_buffer(HEADER_BYTES, data_length);
246
246
  if (!data_buffer) throw deserialize_error('data too short');
247
247
 
248
- /** @type {Array<number>} */
248
+ /** @type {Array<number | undefined>} */
249
249
  let file_offsets;
250
250
  /** @type {number} */
251
251
  let files_start_offset;
@@ -267,6 +267,8 @@ export async function deserialize_binary_form(request) {
267
267
  files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
268
268
  }
269
269
 
270
+ /** @type {Array<{ offset: number, size: number }>} */
271
+ const file_spans = [];
270
272
  const [data, meta] = devalue.parse(text_decoder.decode(data_buffer), {
271
273
  File: ([name, type, size, last_modified, index]) => {
272
274
  if (
@@ -278,28 +280,50 @@ export async function deserialize_binary_form(request) {
278
280
  ) {
279
281
  throw deserialize_error('invalid file metadata');
280
282
  }
281
- if (files_start_offset + file_offsets[index] + size > content_length) {
283
+
284
+ let offset = file_offsets[index];
285
+
286
+ // Check that the file offset table entry has not been already
287
+ // used. If not, immediately mark it as used.
288
+ if (offset === undefined) {
289
+ throw deserialize_error('duplicate file offset table index');
290
+ }
291
+ file_offsets[index] = undefined;
292
+
293
+ offset += files_start_offset;
294
+ if (offset + size > content_length) {
282
295
  throw deserialize_error('file data overflow');
283
296
  }
284
- return new Proxy(
285
- new LazyFile(
286
- name,
287
- type,
288
- size,
289
- last_modified,
290
- get_chunk,
291
- files_start_offset + file_offsets[index]
292
- ),
293
- {
294
- getPrototypeOf() {
295
- // Trick validators into thinking this is a normal File
296
- return File.prototype;
297
- }
297
+
298
+ file_spans.push({ offset, size });
299
+
300
+ return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), {
301
+ getPrototypeOf() {
302
+ // Trick validators into thinking this is a normal File
303
+ return File.prototype;
298
304
  }
299
- );
305
+ });
300
306
  }
301
307
  });
302
308
 
309
+ // Sort file spans in increasing order primarily by offset
310
+ // and secondarily by size (to allow 0-length files).
311
+ file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
312
+
313
+ // Check that file spans do not overlap and there are no gaps between them.
314
+ for (let i = 1; i < file_spans.length; i++) {
315
+ const previous = file_spans[i - 1];
316
+ const current = file_spans[i];
317
+
318
+ const previous_end = previous.offset + previous.size;
319
+ if (previous_end < current.offset) {
320
+ throw deserialize_error('gaps in file data');
321
+ }
322
+ if (previous_end > current.offset) {
323
+ throw deserialize_error('overlapping file data');
324
+ }
325
+ }
326
+
303
327
  // Read the request body asyncronously so it doesn't stall
304
328
  void (async () => {
305
329
  let has_more = true;
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '2.53.2';
4
+ export const VERSION = '2.53.3';