Fix Calendar: Uppercase MAILTO calendar addresses become invalid SMTP recipients
This commit is contained in:
@@ -8,9 +8,12 @@ use super::{
|
||||
ArchivedCalendar, ArchivedCalendarEvent, ArchivedCalendarPreferences, ArchivedDefaultAlert,
|
||||
ArchivedTimezone, Calendar, CalendarEvent, CalendarPreferences, DefaultAlert, Timezone,
|
||||
};
|
||||
use crate::calendar::{
|
||||
ArchivedCalendarEventNotification, ArchivedChangedBy, ArchivedEventPreferences,
|
||||
CalendarEventNotification, ChangedBy, EventPreferences,
|
||||
use crate::{
|
||||
calendar::{
|
||||
ArchivedCalendarEventNotification, ArchivedChangedBy, ArchivedEventPreferences,
|
||||
CalendarEventNotification, ChangedBy, EventPreferences,
|
||||
},
|
||||
strip_mailto_scheme,
|
||||
};
|
||||
use ahash::AHashSet;
|
||||
use calcard::icalendar::{
|
||||
@@ -463,7 +466,7 @@ impl ArchivedCalendarEvent {
|
||||
_ => None,
|
||||
}))
|
||||
{
|
||||
let value = value.strip_prefix("mailto:").unwrap_or(value).trim();
|
||||
let value = strip_mailto_scheme(value);
|
||||
let lang = if is_lang {
|
||||
detector.detect(value, MIN_LANGUAGE_SCORE);
|
||||
Language::Unknown
|
||||
|
||||
@@ -149,3 +149,10 @@ impl DavCalendarResource for DavResources {
|
||||
.map(|p| p.tz)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn strip_mailto_scheme(value: &str) -> &str {
|
||||
value
|
||||
.split_once(':')
|
||||
.filter(|(scheme, _)| scheme.eq_ignore_ascii_case("mailto"))
|
||||
.map_or(value, |(_, address)| address.trim())
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use crate::strip_mailto_scheme;
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use calcard::{
|
||||
common::{IanaString, PartialDateTime},
|
||||
@@ -238,7 +239,7 @@ impl Attendee<'_> {
|
||||
impl Email {
|
||||
pub fn new(email: &str, local_addresses: &[String]) -> Option<Self> {
|
||||
email.contains('@').then(|| {
|
||||
let email = email.trim().trim_start_matches("mailto:").to_lowercase();
|
||||
let email = strip_mailto_scheme(email.trim()).to_lowercase();
|
||||
let is_local = local_addresses.contains(&email);
|
||||
Email { email, is_local }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user