3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-12-25 06:17:02 +00:00

validate compression level input better

This commit is contained in:
StephenHodgson 2025-12-13 16:39:21 -05:00
parent 114dd526d5
commit e4df80e331
3 changed files with 21 additions and 10 deletions

11
dist/restore/index.js vendored
View file

@ -44358,12 +44358,15 @@ function getInputAsInt(name, options) {
return value;
}
function getCompressionLevel(name, options) {
const compressionLevel = getInputAsInt(name, options);
if (compressionLevel === undefined) {
const rawValue = core.getInput(name, options);
if (rawValue === "") {
return undefined;
}
if (compressionLevel > 9) {
logWarning(`Invalid compression-level provided: ${compressionLevel}. Expected a value between 0 (no compression) and 9 (maximum compression).`);
const compressionLevel = parseInt(rawValue, 10);
if (isNaN(compressionLevel) ||
compressionLevel < 0 ||
compressionLevel > 9) {
logWarning(`Invalid compression-level provided: ${rawValue}. Expected a value between 0 (no compression) and 9 (maximum compression).`);
return undefined;
}
return compressionLevel;