diff --git a/crates/types/src/id.rs b/crates/types/src/id.rs index 2befedc..d598f34 100644 --- a/crates/types/src/id.rs +++ b/crates/types/src/id.rs @@ -36,6 +36,13 @@ impl FromStr for Id { type Err = (); fn from_str(s: &str) -> Result { + // inbuxa: an empty id is not id 0. RFC 8620 ยง1.2 ids are 1 to 255 + // characters, and "" would otherwise name each collection's first + // document: `mailboxIds: {"": true}` filed a message in the Inbox. + if s.is_empty() { + return Err(()); + } + let mut id = 0; for &ch in s.as_bytes() { @@ -261,4 +268,10 @@ mod tests { Id::from_str("p333333333333p333333333333").unwrap(); } + + #[test] + fn empty_jmap_id_is_refused() { + assert!(Id::from_str("").is_err()); + assert_eq!(Id::from_str("a").unwrap(), Id::from(0u64)); + } }