Skip to content

Commit b438fb2

Browse files
committed
make sure session name does not contain illegal characters
1 parent 5628d88 commit b438fb2

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

dist/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22586,15 +22586,20 @@ function setOutputs(accessKeyId, accessKeySecret, securityToken) {
2258622586
}
2258722587
exports.setOutputs = setOutputs;
2258822588
function genSessionName(rawName) {
22589+
const replaceIllegalCharacters = function (s) {
22590+
return s.replace(/[^-\w.@]/g, '@');
22591+
};
2258922592
let finalName = rawName;
2259022593
if (finalName.length < 2) {
2259122594
finalName = 'github-actions-<orgName>-<repoName>';
2259222595
}
2259322596
if (finalName.includes('<orgName>')) {
22594-
finalName = finalName.replace('<orgName>', github.context.repo.owner);
22597+
const orgName = github.context.repo.owner;
22598+
finalName = finalName.replace('<orgName>', replaceIllegalCharacters(orgName));
2259522599
}
2259622600
if (finalName.includes('<repoName>')) {
22597-
finalName = finalName.replace('<repoName>', github.context.repo.repo);
22601+
const repoName = github.context.repo.repo;
22602+
finalName = finalName.replace('<repoName>', replaceIllegalCharacters(repoName));
2259822603
}
2259922604
if (finalName.length >= 64) {
2260022605
finalName = finalName.slice(0, 63);

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9630,15 +9630,20 @@ function setOutputs(accessKeyId, accessKeySecret, securityToken) {
96309630
}
96319631
exports.setOutputs = setOutputs;
96329632
function genSessionName(rawName) {
9633+
const replaceIllegalCharacters = function (s) {
9634+
return s.replace(/[^-\w.@]/g, '@');
9635+
};
96339636
let finalName = rawName;
96349637
if (finalName.length < 2) {
96359638
finalName = 'github-actions-<orgName>-<repoName>';
96369639
}
96379640
if (finalName.includes('<orgName>')) {
9638-
finalName = finalName.replace('<orgName>', github.context.repo.owner);
9641+
const orgName = github.context.repo.owner;
9642+
finalName = finalName.replace('<orgName>', replaceIllegalCharacters(orgName));
96399643
}
96409644
if (finalName.includes('<repoName>')) {
9641-
finalName = finalName.replace('<repoName>', github.context.repo.repo);
9645+
const repoName = github.context.repo.repo;
9646+
finalName = finalName.replace('<repoName>', replaceIllegalCharacters(repoName));
96429647
}
96439648
if (finalName.length >= 64) {
96449649
finalName = finalName.slice(0, 63);

dist/post/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,20 @@ export function setOutputs(accessKeyId: string, accessKeySecret: string, securit
4141
}
4242

4343
export function genSessionName(rawName: string) {
44+
const replaceIllegalCharacters = function (s: string) {
45+
return s.replace(/[^-\w.@]/g, '@');
46+
};
4447
let finalName = rawName;
4548
if (finalName.length < 2) {
4649
finalName = 'github-actions-<orgName>-<repoName>';
4750
}
4851
if (finalName.includes('<orgName>')) {
49-
finalName = finalName.replace('<orgName>', github.context.repo.owner);
52+
const orgName = github.context.repo.owner;
53+
finalName = finalName.replace('<orgName>', replaceIllegalCharacters(orgName));
5054
}
5155
if (finalName.includes('<repoName>')) {
52-
finalName = finalName.replace('<repoName>', github.context.repo.repo);
56+
const repoName = github.context.repo.repo;
57+
finalName = finalName.replace('<repoName>', replaceIllegalCharacters(repoName));
5358
}
5459
if (finalName.length >= 64) {
5560
finalName = finalName.slice(0, 63);

0 commit comments

Comments
 (0)