trim only ascii whitespace for branch - #2521
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a potential safety issue where @actions/core’s default whitespace trimming can strip certain Unicode characters (e.g., BOM/NBSP) from the ref input, causing an unintended reclassification of a ref-like value as a commit SHA and impacting the unsafe fork PR checkout guard.
Changes:
- Add ASCII-only trimming logic for
refto avoid Unicode character stripping when determining whether the value is a raw SHA. - Extend unit tests to cover BOM-prefixed SHA-like refs and ASCII-whitespace-surrounded SHAs.
- Regenerate
dist/index.jsto include the updated behavior.
Show a summary per file
| File | Description |
|---|---|
src/input-helper.ts |
Introduces ASCII-only trimming for SHA detection on ref to avoid Unicode-trim surprises. |
__test__/input-helper.test.ts |
Updates getInput mocking and adds regression tests for BOM + SHA-like inputs. |
dist/index.js |
Bundled output reflecting the source change. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/3 changed files
- Comments generated: 2
- Review effort level: Low
rentziass
approved these changes
Jul 15, 2026
This was referenced Jul 16, 2026
Merged
1 task
This was referenced Jul 27, 2026
1 task
20 tasks
1 task
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.
Fixes https://github.com/github/c2c-actions/issues/10325