diff options
Diffstat (limited to 'mailnews/mime/src')
-rw-r--r-- | mailnews/mime/src/MimeHeaderParser.cpp | 18 | ||||
-rw-r--r-- | mailnews/mime/src/mimeJSComponents.js | 17 |
2 files changed, 28 insertions, 7 deletions
diff --git a/mailnews/mime/src/MimeHeaderParser.cpp b/mailnews/mime/src/MimeHeaderParser.cpp index 4fd7bc982..15341de46 100644 --- a/mailnews/mime/src/MimeHeaderParser.cpp +++ b/mailnews/mime/src/MimeHeaderParser.cpp @@ -107,6 +107,24 @@ nsCOMArray<msgIAddressObject> EncodedHeader(const nsACString &aHeader, return retval; } +nsCOMArray<msgIAddressObject> EncodedHeaderW(const nsAString &aHeader) +{ + nsCOMArray<msgIAddressObject> retval; + if (aHeader.IsEmpty()) { + return retval; + } + nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser()); + NS_ENSURE_TRUE(headerParser, retval); + msgIAddressObject **addresses = nullptr; + uint32_t length; + nsresult rv = headerParser->ParseEncodedHeaderW(aHeader, &length, &addresses); + MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!"); + if (NS_SUCCEEDED(rv) && length > 0 && addresses) { + retval.Adopt(addresses, length); + } + return retval; +} + void ExtractAllAddresses(const nsCOMArray<msgIAddressObject> &aHeader, nsTArray<nsString> &names, nsTArray<nsString> &emails) { diff --git a/mailnews/mime/src/mimeJSComponents.js b/mailnews/mime/src/mimeJSComponents.js index 5ba7ff084..8e9d0684a 100644 --- a/mailnews/mime/src/mimeJSComponents.js +++ b/mailnews/mime/src/mimeJSComponents.js @@ -269,6 +269,15 @@ MimeAddressParser.prototype = { MimeParser.HEADER_ADDRESS | MimeParser.HEADER_OPTION_ALL_I18N, aCharset); return fixArray(value, aPreserveGroups, count); }, + parseEncodedHeaderW: function (aHeader, count) { + aHeader = aHeader || ""; + let value = MimeParser.parseHeaderField(aHeader, + MimeParser.HEADER_ADDRESS | + MimeParser.HEADER_OPTION_DECODE_2231 | + MimeParser.HEADER_OPTION_DECODE_2047, + undefined); + return fixArray(value, false, count); + }, parseDecodedHeader: function (aHeader, aPreserveGroups, count) { aHeader = aHeader || ""; let value = MimeParser.parseHeaderField(aHeader, MimeParser.HEADER_ADDRESS); @@ -390,13 +399,7 @@ MimeAddressParser.prototype = { parseHeadersWithArray: function (aHeader, aAddrs, aNames, aFullNames) { let addrs = [], names = [], fullNames = []; - // Parse header, but without HEADER_OPTION_ALLOW_RAW. - let value = MimeParser.parseHeaderField(aHeader || "", - MimeParser.HEADER_ADDRESS | - MimeParser.HEADER_OPTION_DECODE_2231 | - MimeParser.HEADER_OPTION_DECODE_2047, - undefined); - let allAddresses = fixArray(value, false); + let allAddresses = this.parseEncodedHeader(aHeader, undefined, false); // Don't index the dummy empty address. if (aHeader.trim() == "") |