Skip to content

fix: update regex for multipart content-type parsing in multipleRange #9064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Apr 27, 2025

The Content-Type response is as follows: Content-Type: multipart/byteranges; boundary=799ddd5a-943e-4e22-981d-e32596ca39d2. The boundary can have a space before it or no space at all.
Here's the rfc:
https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1
image

Issue

Currently, the check only accounts for cases where there is a space. If some servers return a response without a space, it will cause incremental downloads to fail.

Error Info

17:13:29.256 > Full: 92,770.98 KB, To download: 19,742.1 KB (21%)
17:13:29.633 > Cannot download differentially, fallback to full download: Error: Content-Type "multipart/byteranges" is expected, but got "multipart/byteranges;boundary=e888c103-165d-4ec1-9b6f-eca722ac9b10"
    at ClientRequest.<anonymous> (C:\Users\payne\AppData\Local\Programs\Cherry Studio\resources\app.asar\node_modules\electron-updater\out\differentialDownloader\multipleRangeDownloader.js:80:20)
    at ClientRequest.emit (node:events:531:35)
    at SimpleURLLoaderWrapper.<anonymous> (node:electron/js2c/browser_init:2:114720)
    at SimpleURLLoaderWrapper.emit (node:events:519:28)
17:13:34.288 > New version 1.2.9 has been downloaded to C:\Users\payne\AppData\Local\cherrystudio-updater\pending\Cherry-Studio-1.2.9-x64-setup.exe

How to fix

Welcome to Node.js v22.14.0.
Type ".help" for more information.
> /^multipart\/.+?\s*;\s*boundary=(?:"([^"]+)"|([^\s";]+))\s*$/i.exec("multipart/byteranges;boundary=799ddd5a-943e-4e22-981d-e32596ca39d2")
[
  'multipart/byteranges;boundary=799ddd5a-943e-4e22-981d-e32596ca39d2',
  undefined,
  '799ddd5a-943e-4e22-981d-e32596ca39d2',
  index: 0,
  input: 'multipart/byteranges;boundary=799ddd5a-943e-4e22-981d-e32596ca39d2',
  groups: undefined
]
> /^multipart\/.+?\s*;\s*boundary=(?:"([^"]+)"|([^\s";]+))\s*$/i.exec("multipart/byteranges; boundary=799ddd5a-943e-4e22-981d-e32596ca39d2")
[
  'multipart/byteranges; boundary=799ddd5a-943e-4e22-981d-e32596ca39d2',
  undefined,
  '799ddd5a-943e-4e22-981d-e32596ca39d2',
  index: 0,
  input: 'multipart/byteranges; boundary=799ddd5a-943e-4e22-981d-e32596ca39d2',
  groups: undefined
]

might fix #9063

Copy link

changeset-bot bot commented Apr 27, 2025

🦋 Changeset detected

Latest commit: 350adb3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Differential download must fail after 10 seconds
1 participant