From 701936be7871a6857391102466be251c10f70319 Mon Sep 17 00:00:00 2001 From: Gitea Actions Date: Sat, 3 May 2025 18:01:36 +0000 Subject: [PATCH] Deploy version 1.2.0 --- dist/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0ae5f3d..8299e3a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -26242,6 +26242,14 @@ function expandPath(p) { ); return import_path.default.resolve(p); } +function sanitizeKey(key) { + key = key.trim(); + key = key.replace(/[^a-zA-Z0-9._-]/g, "_"); + if (key.length === 0) { + throw new Error("Cache key cannot be empty after sanitization."); + } + return key; +} // src/cache.ts async function uploadCache(options, owner, repo, key, filePath) { @@ -26317,7 +26325,7 @@ async function createCompressedTar(key, paths, cmprss_lvl = 3) { throw new Error("No paths specified for archiving."); } const tempDir = await fs3.promises.mkdtemp(path2.join(os2.tmpdir(), "cache-")); - const archivePath = path2.join(tempDir, `${key}.tar.zst`); + const archivePath = path2.join(tempDir, `${sanitizeKey(key)}.tar.zst`); const quotedPaths = paths.map((p) => `"${expandPath(p)}"`).join(" "); const cmd = `tar -cf - ${quotedPaths} | zstd -${cmprss_lvl} -o "${archivePath}"`; console.log(` @@ -26386,7 +26394,7 @@ var fs5 = __toESM(require("fs")); async function restoreCache(key) { core3.info(`\u{1F4E6} Starting cache restore for key: ${key}`); const startTime = Date.now(); - const zstPath = `/tmp/${key}.tar.zst`; + const zstPath = `/tmp/${sanitizeKey(key)}.tar.zst`; const { owner, repo } = getRepoInfo(); const downloaded = await downloadCache( { serverUrl: getServerUrl(), token: getToken() },