mirror of
https://github.com/actions/checkout.git
synced 2026-01-21 08:08:54 +08:00
Improve tests to verify user-agent content and handle empty sanitized IDs
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
parent
dbf1fa69f1
commit
4b8779770e
3 changed files with 74 additions and 8 deletions
5
dist/index.js
vendored
5
dist/index.js
vendored
|
|
@ -1213,7 +1213,10 @@ class GitCommandManager {
|
|||
// Sanitize the orchestration ID to ensure it contains only valid characters
|
||||
// Valid characters: 0-9, a-z, _, -, .
|
||||
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
|
||||
gitHttpUserAgent = `${gitHttpUserAgent} actions_orchestration_id/${sanitizedId}`;
|
||||
// Only append if sanitized ID contains at least one alphanumeric character
|
||||
if (sanitizedId && /[a-z0-9]/i.test(sanitizedId)) {
|
||||
gitHttpUserAgent = `${gitHttpUserAgent} actions_orchestration_id/${sanitizedId}`;
|
||||
}
|
||||
}
|
||||
core.debug(`Set git useragent to: ${gitHttpUserAgent}`);
|
||||
this.gitEnv['GIT_HTTP_USER_AGENT'] = gitHttpUserAgent;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue