nextcloud/core/src/utils
Anna Larch 2aa944a80f fix(core): use btoa() instead of window.Buffer.from() for base64 encoding
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>
2026-05-04 19:48:19 +02:00
..
ClipboardFallback.ts chore: adjust code to new codestyle 2025-10-02 13:19:42 +02:00
RedirectUnsupportedBrowsers.js fix(core): use btoa() instead of window.Buffer.from() for base64 encoding 2026-05-04 19:48:19 +02:00
xhr-request.js chore: adjust code to new codestyle 2025-10-02 13:19:42 +02:00