Skip to content

Reject unterminated source map VLQ values - #846

Open
OskarEichler wants to merge 1 commit into
rails:mainfrom
OskarEichler:codex/vlq-source-fix
Open

Reject unterminated source map VLQ values#846
OskarEichler wants to merge 1 commit into
rails:mainfrom
OskarEichler:codex/vlq-source-fix

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

An unterminated VLQ value raises ArgumentError instead of silently returning a partial decoded result.

The pre-#628 decoder rejected unterminated input. This restores that validation while retaining the current single-pass algorithm. Valid signed integers/arrays and invalid characters checked. With full Sprockets loaded, the existing error class resolves to Sprockets::ArgumentError.

Reproduction

With require "sprockets"; require "tmpdir":

p Sprockets::SourceMapUtils.vlq_decode("g")
# Raises the existing ArgumentError type; previously silently returned [].
# A valid prefix followed by an unterminated value no longer returns partial output.

Verification

  • Isolated patch and release baseline: unchanged bundle exec rake test, 913 tests /4,109 assertions /zero failures/errors /four skips, Ruby 3.2.11 and 4.0.6. 628 focused external checks for this patch on each Ruby.
  • Eight follow-ups combined with existing Use Ruby 3 keyword argument handling for find_asset! #792: same suite plus 1,540 focused checks per Ruby. Combined isolated test task also passes. Full RuboCop passes all 133 files; Ruby syntax and diff whitespace checks pass.
  • Gem build preserves 84 file paths, version 4.4.1, Ruby >=2.5 and dependency metadata. Consumer based on installed release/current main 49d9f20c00ac7d9a7ee57db058961edcccd86699, without unrelated upgrades.
  • Existing asset-clean test is timing-sensitive: touching its fixture within the current timestamp second reproduced the same line-80 assertion failure on baseline and an independent cache patch (2/4 each). Full successful runs above are actual runs; no test code was changed. Normal skips cover legacy Ruby, Windows and two Sass cases; non-terminal stdin adds the Unix-device skip.

Compatibility and limitations

Breaking changes: no intentional change to valid supported behavior; the incorrect behavior above changes. Malformed VLQ input now raises instead of returning partial results. No new dependencies or version upgrades. Older Ruby/Linux/JRuby checks are left to upstream CI, not claimed locally. No tests added/edited under the consumer repository's no-test-edit policy; focused evidence was run externally. Prepared with AI assistance. This is a focused correction, not an exhaustive Sprockets review.

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