Allow to parse emails with an invalid base32 code
This commit is contained in:
parent
f4880ddcc2
commit
fd7bf7dffd
1 changed files with 15 additions and 1 deletions
|
@ -27,7 +27,9 @@ impl CodedAddress {
|
|||
None
|
||||
};
|
||||
let code = if parts.len() >= 3 {
|
||||
BASE32_NOPAD.decode(parts[2].to_uppercase().as_bytes())?
|
||||
BASE32_NOPAD
|
||||
.decode(parts[2].to_uppercase().as_bytes())
|
||||
.unwrap_or(Vec::new())
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
@ -158,6 +160,18 @@ mod tests {
|
|||
assert_eq!(addr.domain, Some("example.org".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_valid_coded_addr_with_invalid_base32() {
|
||||
let addr_str = "a+test+invalid@example.org";
|
||||
let addr = CodedAddress::parse(addr_str, '+');
|
||||
assert!(addr.is_ok(), "unable to parse {addr_str}: {addr:?}");
|
||||
let addr = addr.unwrap();
|
||||
assert_eq!(addr.local_part, "a");
|
||||
assert_eq!(addr.sub_addr, Some("test".to_string()));
|
||||
assert_eq!(addr.code, Vec::new());
|
||||
assert_eq!(addr.domain, Some("example.org".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_valid_coded_addr_without_domain() {
|
||||
let addr_str = "local.part+test+orsxg5a";
|
||||
|
|
Loading…
Reference in a new issue