From 0991f5c5007c440898ffe0f2b0c7cfc0f931c497 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Mon, 15 Apr 2019 18:48:32 +0200 Subject: Fix parse_auth to make it RFC-compliant + updated comments --- src/args.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/args.rs b/src/args.rs index f858308..5a0b5db 100644 --- a/src/args.rs +++ b/src/args.rs @@ -89,6 +89,7 @@ fn parse_auth(src: &str) -> Result<(String, String), String> { }; let password = match split.next() { + // This allows empty passwords, as the spec does not forbid it Some(password) => password, None => { return Err( @@ -96,10 +97,12 @@ fn parse_auth(src: &str) -> Result<(String, String), String> { ) } }; - // Should we allow empty passwords ? - if username.len() > 255 { - return Err("Username length cannot exceed 255 characters".to_owned()); + // To make it Windows-compatible,the password needs to be shorter than 255 characters. + // After 255 characters, Windows will truncate the value. + // As for the username, the spec does not mention a limit in length + if password.len() > 255 { + return Err("Password length cannot exceed 255 characters".to_owned()); } Ok((username.to_owned(), password.to_owned())) -- cgit v1.2.3