fix(core): use btoa() instead of window.Buffer.from() for base64 encoding#60148
Merged
nickvergessen merged 2 commits intomasterfrom May 5, 2026
Merged
fix(core): use btoa() instead of window.Buffer.from() for base64 encoding#60148nickvergessen merged 2 commits intomasterfrom
nickvergessen merged 2 commits intomasterfrom
Conversation
…ding window.Buffer is a Node.js API that is not natively available in browsers. It was apparently polyfilled in the webpack bundle by a dependency, but the polyfill is absent in environments like headless Electron (Cypress). This went undetected because browserslist-useragent-regexp < 4.1.4 had a bug where an empty browser set produced /(?:)/ (matches everything). Electron matched as "supported" and the redirect code was never reached. browserslist-useragent-regexp 4.1.4 fixed that bug (PR #1583: faithfully match an empty set of browsers), generating /[]/ instead. Electron 118 no longer matches as supported, the redirect path is now exercised, and window.Buffer.from() throws: TypeError: Cannot read properties of undefined (reading 'from') The fix replaces window.Buffer.from(str).toString('base64') with the native browser btoa(str), which has been universally available since before our minimum browser support baseline and requires no polyfill. Fixes: #57920 Signed-off-by: Anna Larch <anna@nextcloud.com>
Contributor
Author
|
/compile amend |
65d6e18 to
8ad3591
Compare
Covers the main logic paths: supported browser (no redirect), unsupported browser (redirect with btoa-encoded URL), already on the warning page (no double redirect), and a no-throw guard that would have caught the window.Buffer regression. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
34ad541 to
ef0db44
Compare
nickvergessen
approved these changes
May 4, 2026
susnux
approved these changes
May 4, 2026
Contributor
susnux
left a comment
There was a problem hiding this comment.
Should be polyfilled? Anyways this makes sense
Contributor
Author
|
/backport to stable33 |
Contributor
Author
|
/backport to stable32 |
4 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
window.Buffer is a Node.js API that is not natively available in browsers. It was apparently polyfilled in the webpack bundle by a dependency, but the polyfill is absent in environments like headless Electron (Cypress).
This went undetected because browserslist-useragent-regexp < 4.1.4 had a bug where an empty browser set produced /(?:)/ (matches everything). Electron matched as "supported" and the redirect code was never reached.
browserslist-useragent-regexp 4.1.4 fixed that bug (PR #1583: faithfully match an empty set of browsers), generating /[]/ instead. Electron 118 no longer matches as supported, the redirect path is now exercised, and window.Buffer.from() throws:
TypeError: Cannot read properties of undefined (reading 'from')The fix replaces window.Buffer.from(str).toString('base64') with the native browser btoa(str), which has been universally available since before our minimum browser support baseline and requires no polyfill.
Fixes: #57920
Checklist
3. to review, feature component)stable32)AI (if applicable)