1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-25 05:40:29 +01:00

Convert email domains to punycode

Dieser Commit ist enthalten in:
Daniel García 2020-01-30 22:11:53 +01:00
Ursprung 2798f623d4
Commit def174a517
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: FC8A7D14C3CD543A
4 geänderte Dateien mit 1150 neuen und 1146 gelöschten Zeilen

2280
Cargo.lock generiert

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -111,6 +111,8 @@ openssl = "0.10.26"
# URL encoding library
percent-encoding = "2.1.0"
# Punycode conversion
idna = "0.2.0"
[patch.crates-io]
# Use newest ring

Datei anzeigen

@ -271,7 +271,7 @@ impl EmailTokenData {
/// Takes an email address and obscures it by replacing it with asterisks except two characters.
pub fn obscure_email(email: &str) -> String {
let split: Vec<&str> = email.split('@').collect();
let split: Vec<&str> = email.rsplitn(2, '@').collect();
let mut name = split[0].to_string();
let domain = &split[1];

Datei anzeigen

@ -259,6 +259,18 @@ pub fn send_change_email(address: &str, token: &str) -> EmptyResult {
}
fn send_email(address: &str, subject: &str, body_html: &str, body_text: &str) -> EmptyResult {
let address_split: Vec<&str> = address.rsplitn(2, '@').collect();
if address_split.len() != 2 {
err!("Invalid email address (no @)");
}
let domain_puny = match idna::domain_to_ascii_strict(address_split[1]) {
Ok(d) => d,
Err(_) => err!("Can't convert email domain to ASCII representation"),
};
let address = format!("{}@{}", address_split[0], domain_puny);
let html = PartBuilder::new()
.body(encode_to_str(body_html))
.header(("Content-Type", "text/html; charset=utf-8"))