From 41922faabae94c797466571fa4f900846c8db00d Mon Sep 17 00:00:00 2001 From: Michal Trybus Date: Wed, 18 Mar 2026 17:49:42 +0100 Subject: [PATCH] Relax regex used to match the username in remote URL (#81) Adjusted to match from RFC 1738. --- src/gerrit_project.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gerrit_project.rs b/src/gerrit_project.rs index 85b31b1..8758229 100644 --- a/src/gerrit_project.rs +++ b/src/gerrit_project.rs @@ -27,7 +27,7 @@ impl GerritProject { r"(?x) ^ ssh:// - (?P[[:word:]]+) + (?P([[:word:]$.+!*'(),;?&=-]|%[0-9a-fA-F]{2})+) @ (?P[[:word:]][[:word:].-]*) : @@ -86,11 +86,13 @@ mod tests { #[test] fn test_gerrit_parse_remote_url() { assert_eq!( - GerritProject::parse_from_remote_url("ssh://rbt@ooga.booga.systems:2022/ouppy/abc") - .unwrap(), + GerritProject::parse_from_remote_url( + "ssh://joe.rbt%8f@ooga.booga.systems:2022/ouppy/abc" + ) + .unwrap(), GerritProject { host: GerritHost { - username: "rbt".to_owned(), + username: "joe.rbt%8f".to_owned(), host: "ooga.booga.systems".to_owned(), port: 2022, }, @@ -98,4 +100,12 @@ mod tests { } ); } + + #[test] + fn test_gerrit_parse_remote_url_fail() { + assert!(GerritProject::parse_from_remote_url( + "ssh://joe.rbt%j@ooga.booga.systems:2022/ouppy/abc", + ) + .is_err()); + } }