Percent encoding workaround for Apple Calendar bug

This commit is contained in:
mdecimus
2025-06-07 20:15:42 +02:00
parent d48418b258
commit afd8febbf1
12 changed files with 111 additions and 48 deletions

View File

@@ -6,7 +6,7 @@
use super::GroupwareCache;
use crate::{
DavResourceName,
DavResourceName, RFC_3986,
calendar::{ArchivedCalendar, ArchivedCalendarEvent, Calendar, CalendarEvent},
contact::{AddressBook, ArchivedAddressBook, ArchivedContactCard, ContactCard},
};
@@ -19,7 +19,6 @@ use jmap_proto::types::{
collection::{Collection, SyncCollection},
value::AclGrant,
};
use percent_encoding::NON_ALPHANUMERIC;
use std::sync::Arc;
use store::ahash::{AHashMap, AHashSet};
use tokio::sync::Semaphore;
@@ -98,7 +97,7 @@ pub(super) async fn build_calcard_resources(
DavResourceName::Card
}
.base_path(),
percent_encoding::utf8_percent_encode(&name, NON_ALPHANUMERIC),
percent_encoding::utf8_percent_encode(&name, RFC_3986),
),
paths: AHashSet::with_capacity((container_ids.len() + item_ids.len()) as usize),
resources: Vec::with_capacity((container_ids.len() + item_ids.len()) as usize),

View File

@@ -5,7 +5,7 @@
*/
use crate::{
DavResourceName,
DavResourceName, RFC_3986,
file::{ArchivedFileNode, FileNode},
};
use common::{DavPath, DavResource, DavResourceMetadata, DavResources, Server};
@@ -15,7 +15,6 @@ use jmap_proto::types::{
property::Property,
value::AclGrant,
};
use percent_encoding::NON_ALPHANUMERIC;
use std::sync::Arc;
use store::{
Deserialize, IterateParams, U32_LEN, ValueKey,
@@ -50,7 +49,7 @@ pub(super) async fn build_file_resources(
base_path: format!(
"{}/{}/",
DavResourceName::File.base_path(),
percent_encoding::utf8_percent_encode(&name, NON_ALPHANUMERIC),
percent_encoding::utf8_percent_encode(&name, RFC_3986),
),
size: std::mem::size_of::<DavResources>() as u64,
paths: AHashSet::with_capacity(resources.len()),

View File

@@ -4,11 +4,10 @@
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use crate::{DavResourceName, DestroyArchive};
use crate::{DavResourceName, DestroyArchive, RFC_3986};
use calcard::common::timezone::Tz;
use common::{Server, auth::AccessToken, storage::index::ObjectIndexBuilder};
use jmap_proto::types::collection::{Collection, VanishedCollection};
use percent_encoding::NON_ALPHANUMERIC;
use store::{
U16_LEN, U64_LEN,
write::{Archive, BatchBuilder, TaskQueueClass, ValueClass, key::KeySerializer, now},
@@ -325,7 +324,7 @@ impl ArchivedCalendarEvent {
"webcal://{}{}/{}/{}/{}",
server.core.network.server_name,
DavResourceName::Cal.base_path(),
percent_encoding::utf8_percent_encode(&access_token.name, NON_ALPHANUMERIC),
percent_encoding::utf8_percent_encode(&access_token.name, RFC_3986),
calendar.name,
event_name.name
));

View File

@@ -7,6 +7,7 @@
use calcard::common::timezone::Tz;
use common::DavResources;
use jmap_proto::types::collection::Collection;
use percent_encoding::{AsciiSet, CONTROLS};
pub mod cache;
pub mod calendar;
@@ -21,6 +22,37 @@ pub enum DavResourceName {
Principal,
}
pub const RFC_3986: &AsciiSet = &CONTROLS
.add(b' ')
.add(b'!')
.add(b'"')
.add(b'#')
.add(b'$')
.add(b'%')
.add(b'&')
.add(b'\'')
.add(b'(')
.add(b')')
.add(b'*')
.add(b'+')
.add(b',')
.add(b'/')
.add(b':')
.add(b';')
.add(b'<')
.add(b'=')
.add(b'>')
.add(b'?')
.add(b'@')
.add(b'[')
.add(b'\\')
.add(b']')
.add(b'^')
.add(b'`')
.add(b'{')
.add(b'|')
.add(b'}');
pub struct DestroyArchive<T>(pub T);
impl DavResourceName {