Skip to content

Cap interpolated property string length to prevent amplification#2

Merged
andrew merged 1 commit intomainfrom
fix/interpolation-amplification
May 2, 2026
Merged

Cap interpolated property string length to prevent amplification#2
andrew merged 1 commit intomainfrom
fix/interpolation-amplification

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 2, 2026

Self-referential `` like `${x}${x}${x}` amplify exponentially across interpolation passes. Ten passes of a 5x self-reference would produce ~68 MiB from a tiny input.

Tracks net string growth during each `ReplaceAllStringFunc` pass and stops substituting once the output would exceed 1 MiB. Remaining `${...}` references stay unexpanded, same as unresolvable properties.

Self-referential properties like ${x}${x}${x} can amplify exponentially
across interpolation passes. Tracks net string growth within each pass
and stops substituting once the output would exceed 1 MiB.
@andrew andrew force-pushed the fix/interpolation-amplification branch from 0c9578f to b3e176c Compare May 2, 2026 15:16
@andrew andrew merged commit 5e4e8c1 into main May 2, 2026
2 checks passed
@andrew andrew deleted the fix/interpolation-amplification branch May 2, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant