Repository navigation
fix(base64_encode): encode large input in browser builds - #969
Merged
harttle merged 1 commit intoOct 1, 2026
Merged
Conversation
The browser base64Encode spread every UTF-8 byte of its input into a
single String.fromCharCode call, one argument per byte, so input past
the engine's argument limit threw: past ~125 KB on V8 ("Maximum call
stack size exceeded") and past 64 KB on engines that cap arguments at
65535, such as QuickJS. It now converts the bytes in 32 KB chunks. The
node build, which encodes with Buffer, is unchanged.
Fixes harttle#967
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Owner
|
@all-contributors please add @josefguenther for code |
Contributor
|
I've put up a pull request to add @josefguenther! 🎉 |
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
# [10.30.0](v10.29.0...v10.30.0) (2026-10-01) ### Bug Fixes * **base64_encode:** encode large input in browser builds ([#969](#969)) ([8aace78](8aace78)), closes [#967](#967) * **date:** compute %C and %y from the numeric year ([#961](#961)) ([e68514f](e68514f)) * **date:** compute %U and %W week numbers like strftime ([#958](#958)) ([0587ca8](0587ca8)) * trim custom characters by Unicode code point ([#955](#955)) ([3fe244f](3fe244f)) * **truncatewords:** ignore leading whitespace when counting words ([#954](#954)) ([65e200e](65e200e)) * **url_decode:** keep %2B as a literal plus when decoding ([#939](#939)) ([9af92f5](9af92f5)) ### Features * await promises returned by Drop.valueOf() ([#948](#948)) ([#953](#953)) ([#959](#959)) ([7dfa76b](7dfa76b))
|
🎉 This PR is included in version 10.30.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
The browser
base64Encode(src/build/base64-impl-browser.ts:2) spreads every UTF-8 byte of its input into oneString.fromCharCodecall, one argument per byte, sobase64_encodethrows once the input passes the engine's argument limit.{{ v | base64_encode }}withv = "x".repeat(size), throughdist/liquid.browser.mjsanddist/liquid.browser.umd.js(same result in both):"ok" means the output matches
Buffer.from(v).toString('base64'). That's V8; engines that cap arguments at 65535, such as QuickJS, fail from 64 KB.This converts the bytes in 32 KB chunks. The node build, which encodes with
Buffer, andbase64Decodeare unchanged.The new test in
src/build/base64-impl-browser.spec.tsfails on master and passes here. Its input mixes ASCII and a 4-byte character so that a chunk boundary falls inside a character.npm run build,npm test(1673 tests) andnpm run lintpass on Node 24.11.1.Fixes #967
Written with AI assistance (Claude Code); I have reviewed the change.