Restrict A1Z26 Magic checks to valid ranges (#2644)

This commit is contained in:
Kirill 2026-07-25 10:39:11 +03:00 committed by GitHub
parent 8e19b7e402
commit be42a3b9c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 6 deletions

View File

@ -35,32 +35,32 @@ class A1Z26CipherDecode extends Operation {
]; ];
this.checks = [ this.checks = [
{ {
pattern: "^\\s*([12]?[0-9] )+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6]) )+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["Space"] args: ["Space"]
}, },
{ {
pattern: "^\\s*([12]?[0-9],)+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6]),)+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["Comma"] args: ["Comma"]
}, },
{ {
pattern: "^\\s*([12]?[0-9];)+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6]);)+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["Semi-colon"] args: ["Semi-colon"]
}, },
{ {
pattern: "^\\s*([12]?[0-9]:)+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6]):)+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["Colon"] args: ["Colon"]
}, },
{ {
pattern: "^\\s*([12]?[0-9]\\n)+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6])\\n)+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["Line feed"] args: ["Line feed"]
}, },
{ {
pattern: "^\\s*([12]?[0-9]\\r\\n)+[12]?[0-9]\\s*$", pattern: "^\\s*((?:0?[1-9]|1[0-9]|2[0-6])\\r\\n)+(?:0?[1-9]|1[0-9]|2[0-6])\\s*$",
flags: "", flags: "",
args: ["CRLF"] args: ["CRLF"]
} }

View File

@ -152,5 +152,49 @@ TestRegister.addTests([
args: [1, false, false] args: [1, false, false]
} }
] ]
},
{
name: "Magic: invalid zero A1Z26 values do not match",
input: "0,0",
unexpectedMatch: /A1Z26 Cipher Decode/,
recipeConfig: [
{
op: "Magic",
args: [0, false, false]
}
]
},
{
name: "Magic: invalid high A1Z26 values do not match",
input: "27,1",
unexpectedMatch: /A1Z26 Cipher Decode/,
recipeConfig: [
{
op: "Magic",
args: [0, false, false]
}
]
},
{
name: "Magic: valid leading-zero A1Z26 values match",
input: "26,01",
expectedMatch: /A1Z26 Cipher Decode/,
recipeConfig: [
{
op: "Magic",
args: [0, false, false]
}
]
},
{
name: "Magic: valid leading-zero A1Z26 values match with two digits",
input: "09,10",
expectedMatch: /A1Z26 Cipher Decode/,
recipeConfig: [
{
op: "Magic",
args: [0, false, false]
}
]
} }
]); ]);