Skip to content

Commit e22d980

Browse files
committed
fix: use CRLF newlines in vCards
This is a requirement from <https://datatracker.ietf.org/doc/html/rfc6350#section-3.2>
1 parent 0c0afea commit e22d980

File tree

1 file changed

+22
-22
lines changed
  • deltachat-contact-tools/src

1 file changed

+22
-22
lines changed

deltachat-contact-tools/src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ pub fn make_vcard(contacts: &[VcardContact]) -> String {
7878
let addr = &c.addr;
7979
let display_name = c.display_name();
8080
res += &format!(
81-
"BEGIN:VCARD\n\
82-
VERSION:4.0\n\
83-
EMAIL:{addr}\n\
84-
FN:{display_name}\n"
81+
"BEGIN:VCARD\r\n\
82+
VERSION:4.0\r\n\
83+
EMAIL:{addr}\r\n\
84+
FN:{display_name}\r\n"
8585
);
8686
if let Some(key) = &c.key {
87-
res += &format!("KEY:data:application/pgp-keys;base64,{key}\n");
87+
res += &format!("KEY:data:application/pgp-keys;base64,{key}\r\n");
8888
}
8989
if let Some(profile_image) = &c.profile_image {
90-
res += &format!("PHOTO:data:image/jpeg;base64,{profile_image}\n");
90+
res += &format!("PHOTO:data:image/jpeg;base64,{profile_image}\r\n");
9191
}
9292
if let Some(timestamp) = format_timestamp(c) {
93-
res += &format!("REV:{timestamp}\n");
93+
res += &format!("REV:{timestamp}\r\n");
9494
}
95-
res += "END:VCARD\n";
95+
res += "END:VCARD\r\n";
9696
}
9797
res
9898
}
@@ -559,20 +559,20 @@ END:VCARD",
559559
},
560560
];
561561
let items = [
562-
"BEGIN:VCARD\n\
563-
VERSION:4.0\n\
564-
EMAIL:alice@example.org\n\
565-
FN:Alice Wonderland\n\
566-
KEY:data:application/pgp-keys;base64,[base64-data]\n\
567-
PHOTO:data:image/jpeg;base64,image in Base64\n\
568-
REV:20240418T184242Z\n\
569-
END:VCARD\n",
570-
"BEGIN:VCARD\n\
571-
VERSION:4.0\n\
572-
EMAIL:bob@example.com\n\
573-
FN:bob@example.com\n\
574-
REV:19700101T000000Z\n\
575-
END:VCARD\n",
562+
"BEGIN:VCARD\r\n\
563+
VERSION:4.0\r\n\
564+
EMAIL:alice@example.org\r\n\
565+
FN:Alice Wonderland\r\n\
566+
KEY:data:application/pgp-keys;base64,[base64-data]\r\n\
567+
PHOTO:data:image/jpeg;base64,image in Base64\r\n\
568+
REV:20240418T184242Z\r\n\
569+
END:VCARD\r\n",
570+
"BEGIN:VCARD\r\n\
571+
VERSION:4.0\r\n\
572+
EMAIL:bob@example.com\r\n\
573+
FN:bob@example.com\r\n\
574+
REV:19700101T000000Z\r\n\
575+
END:VCARD\r\n",
576576
];
577577
let mut expected = "".to_string();
578578
for len in 0..=contacts.len() {

0 commit comments

Comments
 (0)