Ver Fonte

Only allow empty passwords when forcing

timvisee há 7 anos atrás
pai
commit
b8a03b89dd
2 ficheiros alterados com 12 adições e 8 exclusões
  1. 0 6
      IDEAS.md
  2. 12 2
      cli/src/util.rs

+ 0 - 6
IDEAS.md

@@ -1,9 +1,6 @@
 # First release
-- Implement `-f` flag for forcing
-- Allow creating non existent directories with the `-f` flag 
 - Only allow file extension renaming on upload with `-f` flag
 - Only allow empty passwords with `-f` flag
-- Implement `-y` flag for assume yes
 - Check for file expiry everywhere
 - Soft limit uploads to 1GB and 2GB
 - Remember all uploaded files, make files listable
@@ -32,9 +29,6 @@
 - Dotfile for default properties
 - Host configuration file for host tags, to easily upload to other hosts
 - Generate man pages
-- Move API URL generator methods out of remote file class
-- Prompt if a file download password is required
-- Must use `-f` to overwrite existing file
 - Rename host to server?
 - Read and write files from and to stdin and stdout with `-` as file
 - Ask to add MIME extension to downloaded files without one on Windows

+ 12 - 2
cli/src/util.rs

@@ -103,13 +103,23 @@ pub fn prompt_password(main_matcher: &MainMatcher) -> String {
         quit_error(err_msg("Missing password, must be specified in no-interact mode").compat());
     }
 
-    // Prompt and return
-    match prompt_password_stderr("Password: ") {
+    // Prompt for the password
+    let password = match prompt_password_stderr("Password: ") {
         Ok(password) => password,
         Err(err) => quit_error(err.context(
             "Failed to read password from password prompt"
         )),
+    };
+
+    // Do not allow empty passwords unless forced
+    if !main_matcher.force() && password.is_empty() {
+        quit_error(err_msg("\
+            An empty password is not supported by the web interface, \
+            use '-f' to force\
+        ").compat())
     }
+
+    password
 }
 
 /// Get a password if required.