Skip to content

Commit a6f1169

Browse files
committed
Fix Sieve message flag parser (closes #1059)
1 parent 4975b21 commit a6f1169

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

crates/jmap-proto/src/types/keyword.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ impl JsonObjectParser for Keyword {
112112

113113
impl From<String> for Keyword {
114114
fn from(value: String) -> Self {
115-
if value.starts_with('$') {
115+
if value
116+
.as_bytes()
117+
.first()
118+
.is_some_and(|&ch| [b'$', b'\\'].contains(&ch))
119+
{
116120
let mut hash = 0;
117121
let mut shift = 0;
118122

119-
for &ch in value.as_bytes() {
123+
for &ch in value.as_bytes().iter().skip(1) {
120124
if shift < 128 {
121-
hash |= (ch as u128) << shift;
125+
hash |= (ch.to_ascii_lowercase() as u128) << shift;
122126
shift += 8;
123127
} else {
124128
break;

tests/resources/jmap/sieve/test_mailbox.sieve

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if not mailboxexists ["Drafts", "Sent Items"] {
3838

3939
# File into new mailboxes using flags
4040
fileinto :create "INBOX / Folder ";
41-
fileinto :flags ["$important", "$seen"] :create "My/Nested/Mailbox/with/multiple/levels";
41+
fileinto :flags ["$important", "\\Seen"] :create "My/Nested/Mailbox/with/multiple/levels";
4242

4343
# Make sure all mailboxes were created
4444
if not mailboxexists "Inbox/Folder" {

tests/src/jmap/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,14 @@ pub async fn jmap_tests() {
381381
email_query_changes::test(&mut params).await;
382382
email_copy::test(&mut params).await;
383383
thread_get::test(&mut params).await;
384-
thread_merge::test(&mut params).await;*/
384+
thread_merge::test(&mut params).await;
385385
mailbox::test(&mut params).await;
386386
delivery::test(&mut params).await;
387387
auth_acl::test(&mut params).await;
388388
auth_limits::test(&mut params).await;
389389
auth_oauth::test(&mut params).await;
390390
event_source::test(&mut params).await;
391-
push_subscription::test(&mut params).await;
391+
push_subscription::test(&mut params).await;*/
392392
sieve_script::test(&mut params).await;
393393
vacation_response::test(&mut params).await;
394394
email_submission::test(&mut params).await;

0 commit comments

Comments
 (0)