fix: GECOS subfield trimming and trailing backslash handling (v0.3.1)
display_name() now returns only the first GECOS subfield (before comma) instead of the full GECOS string with room numbers and phone extensions. split_shell_words() returns None for trailing backslashes instead of silently ignoring them.
This commit is contained in:
+12
-4
@@ -47,14 +47,16 @@ fn split_shell_words(s: &str) -> Option<Vec<String>> {
|
||||
}
|
||||
'\\' if in_double => {
|
||||
// In double quotes, backslash escapes the next char
|
||||
if let Some(next) = chars.next() {
|
||||
current.push(next);
|
||||
match chars.next() {
|
||||
Some(next) => current.push(next),
|
||||
None => return None, // Trailing backslash
|
||||
}
|
||||
}
|
||||
'\\' if !in_single && !in_double => {
|
||||
// Outside quotes, backslash escapes the next char
|
||||
if let Some(next) = chars.next() {
|
||||
current.push(next);
|
||||
match chars.next() {
|
||||
Some(next) => current.push(next),
|
||||
None => return None, // Trailing backslash
|
||||
}
|
||||
}
|
||||
c if c.is_whitespace() && !in_single && !in_double => {
|
||||
@@ -1189,6 +1191,12 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_words_trailing_backslash() {
|
||||
assert_eq!(split_shell_words(r"foo\"), None);
|
||||
assert_eq!(split_shell_words(r#""foo\"#), None);
|
||||
}
|
||||
|
||||
// -- login_worker tests --
|
||||
// These use a real Unix socket pair via UnixListener to simulate greetd.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user