Return error when using blobId in JSContact and JSCalendar (closes #2431)

This commit is contained in:
mdecimus
2025-12-12 18:40:36 +01:00
parent 74cf0dae1e
commit c313ddaa61
2 changed files with 46 additions and 2 deletions

View File

@@ -38,7 +38,10 @@ use jmap_proto::{
use jmap_tools::{JsonPointerHandler, JsonPointerItem, Key, Map, Value}; use jmap_tools::{JsonPointerHandler, JsonPointerItem, Key, Map, Value};
use std::{borrow::Cow, str::FromStr}; use std::{borrow::Cow, str::FromStr};
use store::{ use store::{
ValueKey, ahash::AHashSet, roaring::RoaringBitmap, write::{AlignedBytes, Archive, BatchBuilder, now, serialize::rkyv_deserialize} ValueKey,
ahash::AHashSet,
roaring::RoaringBitmap,
write::{AlignedBytes, Archive, BatchBuilder, now, serialize::rkyv_deserialize},
}; };
use trc::AddContext; use trc::AddContext;
use types::{ use types::{
@@ -802,6 +805,29 @@ fn update_calendar_event<'x>(
.with_property(property) .with_property(property)
.with_description("Invalid value.")); .with_description("Invalid value."));
} }
(
property @ (JSCalendarProperty::Locations | JSCalendarProperty::Participants),
Value::Object(values),
) => {
for (_, value) in values.iter() {
if let Some(values) = value
.as_object_and_get(&Key::Property(JSCalendarProperty::Links))
.and_then(|v| v.as_object())
{
for (_, value) in values.iter() {
if value.as_object().is_some_and(|v| {
v.keys()
.any(|k| matches!(k, Key::Property(JSCalendarProperty::BlobId)))
}) {
return Err(SetError::invalid_properties()
.with_property(property)
.with_description("blobIds in links is not supported."));
}
}
}
}
entries.insert(property, Value::Object(values));
}
(property, value) => { (property, value) => {
if let (JSCalendarProperty::ShowWithoutTime, Value::Bool(set)) = (&property, &value) if let (JSCalendarProperty::ShowWithoutTime, Value::Bool(set)) = (&property, &value)
{ {

View File

@@ -17,7 +17,12 @@ use jmap_proto::{
types::state::State, types::state::State,
}; };
use jmap_tools::{JsonPointerHandler, JsonPointerItem, Key, Value}; use jmap_tools::{JsonPointerHandler, JsonPointerItem, Key, Value};
use store::{ValueKey, ahash::AHashSet, roaring::RoaringBitmap, write::{AlignedBytes, Archive, BatchBuilder}}; use store::{
ValueKey,
ahash::AHashSet,
roaring::RoaringBitmap,
write::{AlignedBytes, Archive, BatchBuilder},
};
use trc::AddContext; use trc::AddContext;
use types::{ use types::{
acl::Acl, acl::Acl,
@@ -468,6 +473,19 @@ fn update_contact_card<'x>(
} }
entries = js_contact.0.as_object_mut().unwrap(); entries = js_contact.0.as_object_mut().unwrap();
} }
(JSContactProperty::Media, Value::Object(media)) => {
for (_, value) in media.iter() {
if value.as_object().is_some_and(|v| {
v.keys()
.any(|k| matches!(k, Key::Property(JSContactProperty::BlobId)))
}) {
return Err(SetError::invalid_properties()
.with_property(JSContactProperty::Media)
.with_description("blobIds in media is not supported."));
}
}
entries.insert(JSContactProperty::Media, Value::Object(media));
}
(property, value) => { (property, value) => {
entries.insert(property, value); entries.insert(property, value);
} }