-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(electron-updater): relax multipart boundary regex to allow no space #9327
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
base: master
Are you sure you want to change the base?
fix(electron-updater): relax multipart boundary regex to allow no space #9327
Conversation
🦋 Changeset detectedLatest commit: a4abb50 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
|
||
| const contentType = safeGetHeader(response, "content-type") | ||
| const m = /^multipart\/.+?\s*;\s*boundary=(?:"([^"]+)"|([^\s";]+))\s*$/i.exec(contentType) | ||
| const m = /^multipart\/.+?\s*;[\s]*boundary=(?:"([^"]+)"|([^\s";]+))\s*$/i.exec(contentType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be adjusted as well?
electron-builder/packages/electron-updater/src/differentialDownloader/multipleRangeDownloader.ts
Line 49 in 08773af
| ranges += `${task.start}-${task.end - 1}, ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not, but adding or omitting spaces after commas in the Range header doesn’t affect functionality. Servers like Alibaba Cloud can recognize both formats, so it's not strictly necessary to add spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just checking this further again. Isn't \s* the same as [\s]*? * is zero or unlimited, so the former version should be the same effectively pre/post-codechange. Right? I might just be needing some coffee though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After checking, I found that a PR was already submitted 6 months ago with the relevant changes. However, the npm package hasn’t been updated yet, so no further action is needed on this. My apologies for the confusion.
Background
Currently,
electron-updateruses a regex to detect multipart responses from the server when performing segmented downloads. The regex requires a space before theboundaryparameter:According to the HTTP standard, the space before boundary is optional. Servers that omit the space will fail detection, causing the updater to incorrectly treat the response as non-multipart, which can disable segmented downloads.
What this PR does
Updates the regex to allow the boundary parameter to appear immediately after the semicolon, removing the requirement for a space.