From 0cff43fe39b208465e525f1cd4d391dc09346407 Mon Sep 17 00:00:00 2001 From: Henry Wilkes Date: Wed, 11 Aug 2021 11:34:17 +0000 Subject: [PATCH] Bug 1718018 - Use vcard content types in place of the deprecated x-vcard. r=mkmelin Differential Revision: https://phabricator.services.mozilla.com/D121744 --- mail/actors/VCardChild.jsm | 2 +- .../thunderbird/net.thunderbird.Thunderbird.appdata.xml | 1 + mail/components/addrbook/content/aboutAddressBook.js | 6 +++--- .../addrbook/test/browser/new/browser_drag_drop.js | 4 ++-- mail/test/browser/attachment/browser_attachmentSize.js | 2 +- .../browser/folder-display/data/test-invalid-vcard.eml | 2 +- .../test/browser/message-window/data/test-vcard-icon.eml | 2 +- mailnews/addrbook/modules/VCardUtils.jsm | 2 +- mailnews/compose/src/MimeEncoder.jsm | 2 +- mailnews/compose/src/nsMsgAttachmentHandler.cpp | 2 +- mailnews/compose/src/nsMsgCompUtils.cpp | 4 ++-- mailnews/compose/src/nsMsgCompose.cpp | 2 +- .../db/gloda/test/unit/test_mime_attachments_size.js | 2 +- mailnews/db/gloda/test/unit/test_mime_emitter.js | 2 +- mailnews/mime/src/mimedrft.cpp | 3 ++- mailnews/mime/src/mimei.cpp | 3 ++- mailnews/mime/src/mimemult.cpp | 9 ++++++--- 17 files changed, 28 insertions(+), 22 deletions(-) diff --git a/mail/actors/VCardChild.jsm b/mail/actors/VCardChild.jsm index bb8141103b..db43b6c145 100644 --- a/mail/actors/VCardChild.jsm +++ b/mail/actors/VCardChild.jsm @@ -12,7 +12,7 @@ class VCardChild extends JSWindowActorChild { // This link comes from VCardMimeConverter.convertToHTML in VCardUtils.jsm. if (event.target.classList.contains("moz-vcard-badge")) { if (event.button == 0) { - // The href is a data:text/x-vcard URL. + // The href is a data:text/vcard URL. let href = event.target.href; href = href.substring(href.indexOf(",") + 1); this.sendAsyncMessage("addVCard", href); diff --git a/mail/branding/thunderbird/net.thunderbird.Thunderbird.appdata.xml b/mail/branding/thunderbird/net.thunderbird.Thunderbird.appdata.xml index ba19c751ed..7df01972d2 100644 --- a/mail/branding/thunderbird/net.thunderbird.Thunderbird.appdata.xml +++ b/mail/branding/thunderbird/net.thunderbird.Thunderbird.appdata.xml @@ -42,6 +42,7 @@ message/rfc822 x-scheme-handler/mailto text/calendar + text/vcard text/x-vcard diff --git a/mail/components/addrbook/content/aboutAddressBook.js b/mail/components/addrbook/content/aboutAddressBook.js index f80bb8c4fa..703e28e9be 100644 --- a/mail/components/addrbook/content/aboutAddressBook.js +++ b/mail/components/addrbook/content/aboutAddressBook.js @@ -1140,14 +1140,14 @@ var cardsPane = { // A card implementation may throw NS_ERROR_NOT_IMPLEMENTED. // Don't break drag-and-drop if that happens. let vCard = card.translateTo("vcard"); - event.dataTransfer.setData("text/x-vcard", decodeURIComponent(vCard)); + event.dataTransfer.setData("text/vcard", decodeURIComponent(vCard)); event.dataTransfer.setData( "application/x-moz-file-promise-dest-filename", card.displayName + ".vcf" ); event.dataTransfer.setData( "application/x-moz-file-promise-url", - "data:text/x-vcard," + vCard + "data:text/vcard," + vCard ); event.dataTransfer.setData( "application/x-moz-file-promise", @@ -1173,7 +1173,7 @@ var cardsPane = { getFlavorData(aTransferable, aFlavor, aData) { if (aFlavor == "application/x-moz-file-promise") { let primitive = {}; - aTransferable.getTransferData("text/x-vcard", primitive); + aTransferable.getTransferData("text/vcard", primitive); let vCard = primitive.value.QueryInterface(Ci.nsISupportsString).data; aTransferable.getTransferData( "application/x-moz-file-promise-dest-filename", diff --git a/mail/components/addrbook/test/browser/new/browser_drag_drop.js b/mail/components/addrbook/test/browser/new/browser_drag_drop.js index 2a70e488d8..ed4454e4a4 100644 --- a/mail/components/addrbook/test/browser/new/browser_drag_drop.js +++ b/mail/components/addrbook/test/browser/new/browser_drag_drop.js @@ -150,7 +150,7 @@ add_task(async function test_drag() { let transferUnicode = dataTransfer.getData("text/unicode"); Assert.equal(transferUnicode, "contact 1 "); - let transferVCard = dataTransfer.getData("text/x-vcard"); + let transferVCard = dataTransfer.getData("text/vcard"); Assert.stringContains(transferVCard, `\r\nUID:${contact1.UID}\r\n`); dragService.endDragSession(true); @@ -178,7 +178,7 @@ add_task(async function test_drag() { "contact 1 ,contact 2 ,contact 3 " ); - transferVCard = dataTransfer.getData("text/x-vcard"); + transferVCard = dataTransfer.getData("text/vcard"); Assert.stringContains(transferVCard, `\r\nUID:${contact1.UID}\r\n`); dragService.endDragSession(true); diff --git a/mail/test/browser/attachment/browser_attachmentSize.js b/mail/test/browser/attachment/browser_attachmentSize.js index c7a1c3b407..22bb6784cd 100644 --- a/mail/test/browser/attachment/browser_attachmentSize.js +++ b/mail/test/browser/attachment/browser_attachmentSize.js @@ -137,7 +137,7 @@ var messages = [ { body: textAttachment, filename: "ubik.txt", format: "" }, { body: vcardAttachment, - contentType: "text/x-vcard", + contentType: "text/vcard", filename: "ubik.vcf", encoding: "base64", format: "", diff --git a/mail/test/browser/folder-display/data/test-invalid-vcard.eml b/mail/test/browser/folder-display/data/test-invalid-vcard.eml index 698837901e..6ee2f4865a 100644 --- a/mail/test/browser/folder-display/data/test-invalid-vcard.eml +++ b/mail/test/browser/folder-display/data/test-invalid-vcard.eml @@ -14,7 +14,7 @@ Content-Type: text/plain; charset=UTF-8 has an attached vcf which has invalid data (null) --------------B16B2089EF5F4ADD84A4E66F -Content-Type: text/x-vcard; +Content-Type: text/vcard; name="contentisnull.vcf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; diff --git a/mail/test/browser/message-window/data/test-vcard-icon.eml b/mail/test/browser/message-window/data/test-vcard-icon.eml index 9448cf37ee..7a462ab528 100644 --- a/mail/test/browser/message-window/data/test-vcard-icon.eml +++ b/mail/test/browser/message-window/data/test-vcard-icon.eml @@ -28,7 +28,7 @@ Content-Type: text/html; charset=UTF-8 --sgnirk-111111111111111 -Content-Type: text/x-vcard; charset=UTF-8 +Content-Type: text/vcard; charset=UTF-8 Content-Disposition: attachment; filename="Meister.vcf" BEGIN:VCARD diff --git a/mailnews/addrbook/modules/VCardUtils.jsm b/mailnews/addrbook/modules/VCardUtils.jsm index 5917d14d8e..1175302927 100644 --- a/mailnews/addrbook/modules/VCardUtils.jsm +++ b/mailnews/addrbook/modules/VCardUtils.jsm @@ -333,7 +333,7 @@ VCardMimeConverter.prototype = { - + diff --git a/mailnews/compose/src/MimeEncoder.jsm b/mailnews/compose/src/MimeEncoder.jsm index c3a7703040..046eff6c8c 100644 --- a/mailnews/compose/src/MimeEncoder.jsm +++ b/mailnews/compose/src/MimeEncoder.jsm @@ -131,7 +131,7 @@ class MimeEncoder { this._charset && isCharsetMultiByte && (this._contentType.startsWith("text") || - // text/x-vcard synonym + // text/vcard synonym this._contentType == "application/directory") ) { needsB64 = true; diff --git a/mailnews/compose/src/nsMsgAttachmentHandler.cpp b/mailnews/compose/src/nsMsgAttachmentHandler.cpp index e7e70874a5..252faf2880 100644 --- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp +++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp @@ -371,7 +371,7 @@ nsresult nsMsgAttachmentHandler::PickEncoding(nsIMsgSend* mime_delivery_state) { m_type.LowerCaseEqualsLiteral(TEXT_ENRICHED) || m_type.LowerCaseEqualsLiteral(TEXT_VCARD) || m_type.LowerCaseEqualsLiteral( - APPLICATION_DIRECTORY) || /* text/x-vcard synonym */ + APPLICATION_DIRECTORY) || /* text/vcard synonym */ m_type.LowerCaseEqualsLiteral(TEXT_CSS) || m_type.LowerCaseEqualsLiteral(TEXT_JSSS))) { needsB64 = true; diff --git a/mailnews/compose/src/nsMsgCompUtils.cpp b/mailnews/compose/src/nsMsgCompUtils.cpp index 84a06cb9c8..2bea1726a8 100644 --- a/mailnews/compose/src/nsMsgCompUtils.cpp +++ b/mailnews/compose/src/nsMsgCompUtils.cpp @@ -568,7 +568,7 @@ char* mime_generate_attachment_headers( (PL_strcasecmp(type, TEXT_ENRICHED) == 0) || (PL_strcasecmp(type, TEXT_VCARD) == 0) || (PL_strcasecmp(type, APPLICATION_DIRECTORY) == - 0) || /* text/x-vcard synonym */ + 0) || /* text/vcard synonym */ (PL_strcasecmp(type, TEXT_CSS) == 0) || (PL_strcasecmp(type, TEXT_JSSS) == 0)) || (PL_strcasecmp(encoding, ENCODING_BASE64) != 0)) && @@ -679,7 +679,7 @@ char* mime_generate_attachment_headers( else if (!PL_strcasecmp(type, APPLICATION_OCTET_STREAM) || !PL_strcasecmp(type, TEXT_VCARD) || !PL_strcasecmp(type, - APPLICATION_DIRECTORY)) /* text/x-vcard synonym */ + APPLICATION_DIRECTORY)) /* text/vcard synonym */ buf.AppendLiteral("attachment"); else buf.AppendLiteral("inline"); diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index fd26ea95fb..7e7ad65c4b 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -1177,7 +1177,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, if (NS_SUCCEEDED(rv) && !escapedVCard.IsEmpty()) { nsCString vCardUrl; - vCardUrl = "data:text/x-vcard;charset=utf-8;base64,"; + vCardUrl = "data:text/vcard;charset=utf-8;base64,"; nsCString unescapedData; MsgUnescapeString(escapedVCard, 0, unescapedData); char* result = PL_Base64Encode(unescapedData.get(), 0, nullptr); diff --git a/mailnews/db/gloda/test/unit/test_mime_attachments_size.js b/mailnews/db/gloda/test/unit/test_mime_attachments_size.js index b221a4ddeb..eb2f038a57 100644 --- a/mailnews/db/gloda/test/unit/test_mime_attachments_size.js +++ b/mailnews/db/gloda/test/unit/test_mime_attachments_size.js @@ -166,7 +166,7 @@ var relImage = { var tachVCard = { filename: "bob.vcf", - contentType: "text/x-vcard", + contentType: "text/vcard", encoding: "7bit", body: "begin:vcard\nfn:Bob\nend:vcard\n", }; diff --git a/mailnews/db/gloda/test/unit/test_mime_emitter.js b/mailnews/db/gloda/test/unit/test_mime_emitter.js index f19874ad99..a8850e3ecf 100644 --- a/mailnews/db/gloda/test/unit/test_mime_emitter.js +++ b/mailnews/db/gloda/test/unit/test_mime_emitter.js @@ -125,7 +125,7 @@ var partRelImage = new SyntheticPartLeaf(relImage.body, relImage); var tachVCard = { filename: "bob.vcf", - contentType: "text/x-vcard", + contentType: "text/vcard", encoding: "7bit", body: "begin:vcard\nfn:Bob\nend:vcard\n", }; diff --git a/mailnews/mime/src/mimedrft.cpp b/mailnews/mime/src/mimedrft.cpp index 521c047b76..edbd2092cb 100644 --- a/mailnews/mime/src/mimedrft.cpp +++ b/mailnews/mime/src/mimedrft.cpp @@ -473,7 +473,8 @@ static nsMsgAttachmentData* mime_draft_process_attachments( else tmpFile = mdd->attachments[attachmentsIndex++]; - if (tmpFile->m_type.LowerCaseEqualsLiteral("text/x-vcard")) + if (tmpFile->m_type.LowerCaseEqualsLiteral("text/vcard") || + tmpFile->m_type.LowerCaseEqualsLiteral("text/x-vcard")) tmp->m_realName = tmpFile->m_description; if (tmpFile->m_origUrl) { diff --git a/mailnews/mime/src/mimei.cpp b/mailnews/mime/src/mimei.cpp index c24849d735..f262d72c81 100644 --- a/mailnews/mime/src/mimei.cpp +++ b/mailnews/mime/src/mimei.cpp @@ -441,7 +441,8 @@ MimeObjectClass* mime_find_class(const char* content_type, MimeHeaders* hdrs, #endif if (types_of_classes_to_disallow > 0 && - !PL_strncasecmp(content_type, "text/x-vcard", 12)) + (!PL_strncasecmp(content_type, "text/vcard", 10) || + !PL_strncasecmp(content_type, "text/x-vcard", 12))) /* Use a little hack to prevent some dangerous plugins, which ship with Mozilla, to run. For the truly user-installed plugins, we rely on the judgement diff --git a/mailnews/mime/src/mimemult.cpp b/mailnews/mime/src/mimemult.cpp index a2471a5036..237d62ff93 100644 --- a/mailnews/mime/src/mimemult.cpp +++ b/mailnews/mime/src/mimemult.cpp @@ -437,7 +437,8 @@ static int MimeMultipart_create_child(MimeObject* obj) { !mime_typep(body, (MimeObjectClass*)&mimeMultipartClass) && !((mime_typep(body, (MimeObjectClass*)&mimeExternalObjectClass) || mime_typep(body, (MimeObjectClass*)&mimeSuppressedCryptoClass)) && - !strcmp(body->content_type, "text/x-vcard"))) { + (!strcmp(body->content_type, "text/vcard") || + !strcmp(body->content_type, "text/x-vcard")))) { status = obj->options->decompose_file_init_fn( obj->options->stream_closure, mult->hdrs); if (status < 0) return status; @@ -525,7 +526,8 @@ static int MimeMultipart_close_child(MimeObject* object) { !mime_typep(kid, (MimeObjectClass *)&mimeMultipartClass) && !((mime_typep(kid, (MimeObjectClass *)&mimeExternalObjectClass) || mime_typep(kid, (MimeObjectClass *)&mimeSuppressedCryptoClass)) && - !strcmp(kid->content_type, "text/x-vcard"))) { + (!strcmp(kid->content_type, "text/vcard") || + !strcmp(kid->content_type, "text/x-vcard")))) { status = object->options->decompose_file_close_fn( object->options->stream_closure); if (status < 0) return status; @@ -568,7 +570,8 @@ static int MimeMultipart_parse_child_line(MimeObject* obj, const char* line, !mime_typep(kid, (MimeObjectClass*)&mimeMultipartClass) && !((mime_typep(kid, (MimeObjectClass*)&mimeExternalObjectClass) || mime_typep(kid, (MimeObjectClass*)&mimeSuppressedCryptoClass)) && - !strcmp(kid->content_type, "text/x-vcard"))) + (!strcmp(kid->content_type, "text/vcard") || + !strcmp(kid->content_type, "text/x-vcard")))) return obj->options->decompose_file_output_fn( line, length, obj->options->stream_closure); }
${propertiesTable}