Skip to content

Avoid slicing truncated source map charset values - #65465

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/sourcemap-data-url
Nov 14, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:compiler-fixes/sourcemap-data-url

Conversation

@jakebailey

Copy link
Copy Markdown
Member

A data URL can end before the UTF-8 charset prefix is complete. Check its length before comparing that prefix so malformed metadata follows the existing skip and external-map fallback paths instead of panicking. Keep charset matching case-insensitive.

A data URL can end before the UTF-8 charset prefix is complete.
Check its length before comparing that prefix so malformed metadata
follows the existing skip and external-map fallback paths instead of
panicking. Keep charset matching case-insensitive.
Keep the charset comparison and both length checks tied to a single
local constant so the accepted prefix cannot drift between them.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 04:41
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 13, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change guarding source-map charset parsing against truncated input.

No open issues 🎉

What changed in this PR

This PR prevents source-map parsing from panicking on truncated UTF-8 charset metadata in data URLs, preserving case-insensitive matching and existing external-map fallback behavior.

Changes:

  • Check the charset length before slicing and comparing its prefix.
  • Add parser tests for malformed and valid data URLs.
  • Verify malformed data URLs are skipped and external maps remain usable.
File Description
tsc/​internal/​sourcemap/​source_mapper.go Guards charset parsing against truncated input.
tsc/​internal/​sourcemap/​source_mapper_test.go Adds parser and external-map fallback regression tests.

Review effort: Balanced

@jakebailey Jake Bailey (jakebailey) changed the title Compiler fixes/sourcemap data url Avoid slicing truncated source map charset values Nov 13, 2026
@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 13, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Nov 13, 2026
Merged via the queue into microsoft:main with commit 9f6c5a2 Nov 14, 2026
34 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the compiler-fixes/sourcemap-data-url branch November 14, 2026 00:03
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants