Skip to content

Commit ef3d77e

Browse files
FranciscoTGouveiarami3l
authored andcommitted
fix(toolchain): change regex to reject leading zeros in toolchain name
A regression test was also added.
1 parent 55e46a3 commit ef3d77e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/dist/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl FromStr for ParsedToolchainDesc {
304304
"stable",
305305
// Allow from 1.0.0 through to 9.999.99 with optional patch version
306306
// and optional beta tag
307-
r"[0-9]{1}\.[0-9]{1,3}(?:\.[0-9]{1,2})?(?:-beta(?:\.[0-9]{1,2})?)?",
307+
r"[0-9]{1}\.(?:0|[1-9][0-9]{0,2})(?:\.(?:0|[1-9][0-9]?))?(?:-beta(?:\.[0-9]{1,2})?)?",
308308
]
309309
.join("|")
310310
))
@@ -1358,7 +1358,15 @@ mod tests {
13581358
assert_eq!(parsed.unwrap(), expected, "input: `{input}`");
13591359
}
13601360

1361-
let failure_cases = vec!["anything", "00.0000.000", "3", "", "--", "0.0.0-"];
1361+
let failure_cases = vec![
1362+
"anything",
1363+
"00.0000.000",
1364+
"3",
1365+
"",
1366+
"--",
1367+
"0.0.0-",
1368+
"1.90.01",
1369+
];
13621370

13631371
for input in failure_cases {
13641372
let parsed = input.parse::<ParsedToolchainDesc>();

0 commit comments

Comments
 (0)