Bug 1885285 - Switch some APIs in nsISmtpService to AUTF8String and remove needless decodeURIComponent/encodeURIComponent. r=mkmelin

Nowhere was stated that the string parameters of nsISmtpService.sendMailMessage() had to be URI encoded.

Differential Revision: https://phabricator.services.mozilla.com/D204592

--HG--
extra : amend_source : cc962000c8b45f3a2ee46fdda61e1153a15730ab
This commit is contained in:
Yury Ivanovich 2024-03-15 10:52:14 -07:00
Родитель 0864b3b9cd
Коммит 6b8878b273
7 изменённых файлов: 16 добавлений и 23 удалений

Просмотреть файл

@ -53,9 +53,9 @@ interface nsISmtpService : nsISupports {
* @param aRequest Provides a handle to the running request.
* This parameter may be null.
*/
void sendMailMessage(in nsIFile aFilePath, in string aRecipients,
void sendMailMessage(in nsIFile aFilePath, in AUTF8String aRecipients,
in nsIMsgIdentity aSenderIdentity,
in string aSender,
in AUTF8String aSender,
in AString aPassword,
in nsIUrlListener aUrlListener,
in nsIMsgStatusFeedback aStatusListener,
@ -117,7 +117,7 @@ interface nsISmtpService : nsISupports {
* @param hostname the hostname of the server
* @returns null if no server is found
*/
nsISmtpServer findServer(in string username, in string hostname);
nsISmtpServer findServer(in AUTF8String username, in AUTF8String hostname);
/**
* Look up the server with the given key.

Просмотреть файл

@ -1125,13 +1125,11 @@ export class MessageSend {
const converter = Cc["@mozilla.org/messenger/mimeconverter;1"].getService(
Ci.nsIMimeConverter
);
const encodedRecipients = encodeURIComponent(
converter.encodeMimePartIIStr_UTF8(
recipients.join(","),
true,
0,
Ci.nsIMimeConverter.MIME_ENCODED_WORD_SIZE
)
const encodedRecipients = converter.encodeMimePartIIStr_UTF8(
recipients.join(","),
true,
0,
Ci.nsIMimeConverter.MIME_ENCODED_WORD_SIZE
);
lazy.MsgUtils.sendLogger.debug(
`Delivering mail message <${this._compFields.messageId}>`

Просмотреть файл

@ -110,7 +110,7 @@ export class SmtpService {
fresh = false;
let from = sender;
const to = MailServices.headerParser
.parseEncodedHeaderW(decodeURIComponent(recipients))
.parseEncodedHeaderW(recipients)
.map(rec => rec.email);
if (
@ -127,9 +127,7 @@ export class SmtpService {
.msgGenerateMessageId(userIdentity, null);
}
client.useEnvelope({
from: MailServices.headerParser.parseEncodedHeaderW(
decodeURIComponent(from)
)[0].email,
from: MailServices.headerParser.parseEncodedHeaderW(from)[0].email,
to,
size: messageFile.fileSize,
requestDSN,

Просмотреть файл

@ -779,10 +779,9 @@ nsresult nsMsgMdnGenerator::SendMdnMsg() {
nsCOMPtr<nsIRequest> aRequest;
nsCString identEmail;
m_identity->GetEmail(identEmail);
smtpService->SendMailMessage(m_file, m_dntRrt.get(), m_identity,
identEmail.get(), EmptyString(), this, nullptr,
nullptr, false, ""_ns, getter_AddRefs(aUri),
getter_AddRefs(aRequest));
smtpService->SendMailMessage(
m_file, m_dntRrt, m_identity, identEmail, EmptyString(), this, nullptr,
nullptr, false, ""_ns, getter_AddRefs(aUri), getter_AddRefs(aRequest));
return NS_OK;
}

Просмотреть файл

@ -86,8 +86,7 @@ nsresult nsBeckySettings::CreateSmtpServer(const nsCString& aUserName,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISmtpServer> server;
rv = smtpService->FindServer(aUserName.get(), aServerName.get(),
getter_AddRefs(server));
rv = smtpService->FindServer(aUserName, aServerName, getter_AddRefs(server));
if (NS_FAILED(rv) || !server) {
rv = smtpService->CreateServer(getter_AddRefs(server));

Просмотреть файл

@ -477,7 +477,7 @@ nsresult OutlookSettings::SetSmtpServer(nsIMsgAccountManager* aMgr,
nsAutoCString nativeServerName;
NS_CopyUnicodeToNative(aServer, nativeServerName);
nsCOMPtr<nsISmtpServer> foundServer;
rv = smtpService->FindServer(nativeUserName.get(), nativeServerName.get(),
rv = smtpService->FindServer(nativeUserName, nativeServerName,
getter_AddRefs(foundServer));
if (NS_SUCCEEDED(rv) && foundServer) {
if (aId) SetSmtpServerKey(aId, foundServer);

Просмотреть файл

@ -624,8 +624,7 @@ void WMSettings::SetSmtpServer(mozilla::dom::Document* xmlDoc,
nsCOMPtr<nsISmtpServer> extgServer;
// don't try to make another server
// regardless if username doesn't match
rv = smtpService->FindServer(userName.get(),
NS_ConvertUTF16toUTF8(smtpName).get(),
rv = smtpService->FindServer(userName, NS_ConvertUTF16toUTF8(smtpName),
getter_AddRefs(extgServer));
if (NS_SUCCEEDED(rv) && extgServer) {
// set our account keyed to this smptserver key