From b499fd4b20d72efaa24a7cfe551ba980828d174c Mon Sep 17 00:00:00 2001 From: BlackHoleFox Date: Sat, 4 Jun 2022 20:37:06 -0500 Subject: [PATCH 1/3] Remove serde dependencies from rpassword --- Cargo.toml | 7 +++++-- src/rutil.rs | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9bcdcbb..89f1ddf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,11 @@ readme = "README.md" keywords = ["read", "password", "security", "pass", "getpass"] edition = "2018" +[features] +# Do not use this. Exists only to workaround the `duck` monorepo's structure. +# It is not covered by any semver versioning. +__serde = [] + [target.'cfg(unix)'.dependencies] libc = "0.2" @@ -18,5 +23,3 @@ libc = "0.2" winapi = { version = "0.3", features = ["std", "winnt", "fileapi", "processenv", "winbase", "handleapi", "consoleapi", "minwindef", "wincon"] } [dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" diff --git a/src/rutil.rs b/src/rutil.rs index 0d0962a..8f59a2f 100644 --- a/src/rutil.rs +++ b/src/rutil.rs @@ -2,5 +2,6 @@ pub mod atty; pub mod fix_new_line; pub mod print_tty; pub mod safe_string; +#[cfg(feature = "__serde")] pub mod safe_string_serde; pub mod safe_vec; From a2314ed0a24f3d0bd7eed3db3b8aae38e1eb269e Mon Sep 17 00:00:00 2001 From: Conrad Kleinespel Date: Tue, 12 Jul 2022 22:25:33 +0200 Subject: [PATCH 2/3] Fix use of serde after removing it from rpassword --- Cargo.toml | 6 +++--- src/rutil.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89f1ddf..1b53aa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,7 @@ keywords = ["read", "password", "security", "pass", "getpass"] edition = "2018" [features] -# Do not use this. Exists only to workaround the `duck` monorepo's structure. -# It is not covered by any semver versioning. -__serde = [] +serde = ["dep:serde", "dep:serde_json"] [target.'cfg(unix)'.dependencies] libc = "0.2" @@ -23,3 +21,5 @@ libc = "0.2" winapi = { version = "0.3", features = ["std", "winnt", "fileapi", "processenv", "winbase", "handleapi", "consoleapi", "minwindef", "wincon"] } [dependencies] +serde = { version = "1.0", features = ["derive"], optional = true } +serde_json = { version = "1.0", optional = true } diff --git a/src/rutil.rs b/src/rutil.rs index 8f59a2f..6843278 100644 --- a/src/rutil.rs +++ b/src/rutil.rs @@ -2,6 +2,6 @@ pub mod atty; pub mod fix_new_line; pub mod print_tty; pub mod safe_string; -#[cfg(feature = "__serde")] +#[cfg(feature = "serde")] pub mod safe_string_serde; pub mod safe_vec; From 66f250565403f8d21d43f266ba666c4c0bf9b3b8 Mon Sep 17 00:00:00 2001 From: NovaliX Date: Tue, 12 Jul 2022 23:18:06 +0200 Subject: [PATCH 3/3] Fix a bug where the newline was not added when io error on reader-readline() occured --- src/rpassword/all.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpassword/all.rs b/src/rpassword/all.rs index 5d5bde0..343c09d 100644 --- a/src/rpassword/all.rs +++ b/src/rpassword/all.rs @@ -188,11 +188,15 @@ mod windows { let hidden_input = HiddenInput::new(handle)?; - reader.read_line(&mut password)?; + let reader_return = reader.read_line(&mut password); // Newline for windows which otherwise prints on the same line. println!(); + if reader_return.is_err() { + return Err(reader_return.unwrap_err()); + } + std::mem::drop(hidden_input); super::fix_new_line(password.into_inner())