We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 47805ca commit 918fb46Copy full SHA for 918fb46
src/sudoers/tokens.rs
@@ -13,13 +13,13 @@ pub struct Username(pub SudoString);
13
impl Token for Username {
14
fn construct(text: String) -> Result<Self, String> {
15
// if a '$' occurs in a username, it has to be the final character
16
- if let Some((_, "")) | None = text.split_once('$') {
17
- SudoString::new(text)
18
- .map_err(|e| e.to_string())
19
- .map(Username)
20
- } else {
21
- Err("embedded $ in username".to_string())
+ if text.strip_suffix('$').unwrap_or(&text).contains('$') {
+ return Err("embedded $ in username".to_string());
22
}
+
+ SudoString::new(text)
+ .map_err(|e| e.to_string())
+ .map(Username)
23
24
25
fn accept(c: char) -> bool {
0 commit comments