Compare commits

...

3 Commits

Author SHA1 Message Date
Bilal Elmoussaoui
d7b9602fd3 accounts: Refresh completion model when scanning from qr code
In that case, we add the provider automatically for the user, not refreshing
the completion model means that the user will get a new dialog form to
create the provider a second time with less accurate information than
what exists in the otp uri.

Fixes #422
Fixes #408
2024-06-22 23:27:29 +02:00
Bilal Elmoussaoui
ca2054646a otp-uri: Add a test case for LjL's issue
See Matrix conversation
2024-06-22 22:06:23 +02:00
Bilal Elmoussaoui
17f2b915c2 Update dependencies 2024-06-22 22:06:23 +02:00
7 changed files with 408 additions and 362 deletions

740
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -49,4 +49,4 @@ url = "2.2"
uuid = {version = "1.0", features = ["v4"]}
zbar-rust = "0.0"
zeroize = {version = "1", features = ["zeroize_derive"]}
zip = { version = "0.6.6", features = ["aes-crypto"] }
zip = { version = "2.1", features = ["aes-crypto"] }

View File

@ -8,7 +8,7 @@ version = "0.1.0"
data-encoding = "2.3"
image = {version = "0.25", features = ["ico", "png"], default-features = false}
percent-encoding = "2.1"
quick-xml = "0.31"
quick-xml = "0.33"
reqwest = "0.12"
svg_metadata = "0.5"
tokio = {version = "1.0", default-features = false, features = ["rt-multi-thread", "fs", "io-util", "macros"]}

View File

@ -43,8 +43,9 @@ impl Scrapper {
fn from_string(body: String, base_url: Option<&Url>) -> Result<Self, Error> {
let mut reader = quick_xml::Reader::from_str(&body);
reader.check_end_names(false);
reader.trim_markup_names_in_closing_tags(true);
let config = reader.config_mut();
config.check_end_names = false;
config.trim_markup_names_in_closing_tags = true;
let mut icons = Self::from_reader(&mut reader, base_url);
if let Some(base) = base_url {

View File

@ -117,7 +117,7 @@ impl Restorable for RaivoOTP {
Some(k) => k.as_bytes(),
};
let mut archive = ZipArchive::new(Cursor::new(from))?;
let file = archive.by_name_decrypt("raivo-otp-export.json", password)??;
let file = archive.by_name_decrypt("raivo-otp-export.json", password)?;
let items = serde_json::from_reader(file)?;
Ok(items)
}

View File

@ -10,7 +10,7 @@ use crate::{
};
#[allow(clippy::upper_case_acronyms)]
#[derive(Zeroize, ZeroizeOnDrop)]
#[derive(Debug, PartialEq, Eq, Zeroize, ZeroizeOnDrop)]
pub struct OTPUri {
#[zeroize(skip)]
pub(crate) algorithm: Algorithm,
@ -251,4 +251,19 @@ mod tests {
};
assert_eq!(String::from(uri), "otpauth://totp/account%20test?secret=dznF36H0IIg17rK&issuer=Test&algorithm=SHA1&digits=6&period=30");
}
#[test]
fn ljl_issue() {
let uri = OTPUri {
algorithm: Algorithm::SHA512,
label: "SpidItalia%3REDACTED@REDACTED (persona fisica)".to_owned(),
secret: "REDACTED".to_owned(),
issuer: "SpidItalia".to_owned(),
method: Method::TOTP,
digits: Some(6),
period: Some(30),
counter: None,
};
assert_eq!(OTPUri::from_str("otpauth://totp/SpidItalia%3REDACTED%40REDACTED%20(persona%20fisica)?period=30&digits=6&algorithm=SHA512&secret=REDACTED&issuer=SpidItalia").unwrap(), uri);
}
}

View File

@ -258,6 +258,8 @@ impl AccountAddDialog {
)
.ok();
imp.provider_completion
.set_model(Some(&self.model().completion_model()));
self.set_provider(provider);
}