Fix Calendar: Uppercase MAILTO calendar addresses become invalid SMTP recipients

This commit is contained in:
Maurus Decimus
2026-07-19 10:29:07 +02:00
parent bd44943661
commit 18dbbda298
8 changed files with 34 additions and 21 deletions

View File

@@ -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

View File

@@ -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())
}

View File

@@ -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 }
})