diff options
author | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-15 16:48:32 +0000 |
---|---|---|
committer | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-15 16:48:32 +0000 |
commit | 0991f5c5007c440898ffe0f2b0c7cfc0f931c497 (patch) | |
tree | 8efc4cb048a8bdfc9f469fb3e8babea698f42925 /src | |
parent | Cargo fmt (diff) | |
download | miniserve-0991f5c5007c440898ffe0f2b0c7cfc0f931c497.tar.gz miniserve-0991f5c5007c440898ffe0f2b0c7cfc0f931c497.zip |
Fix parse_auth to make it RFC-compliant + updated comments
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 9 |
1 files changed, 6 insertions, 3 deletions
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())) |