Bug 1885285 - Fix expectation of test_sendMailAddressIDN.js. r=mkmelin

The fix in https://hg.mozilla.org/comm-central/rev/8aa30c8f177d#l1.12 wasn't correct.
An empty recipient shouldn't be forced to NS_ERROR_ILLEGAL_LOCALPART with a missing error insert in
There are non-ASCII characters in the local part of the recipient address %s and your server does not support SMTPUTF8.

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

--HG--
extra : amend_source : 88609ae6978b9d2c00a16cb76f58da5d27a7d2ee
This commit is contained in:
Yury Ivanovich 2024-03-15 10:51:41 -07:00
Родитель 18b206dfce
Коммит 0864b3b9cd
2 изменённых файлов: 21 добавлений и 7 удалений

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

@ -221,6 +221,11 @@ export class SmtpClient {
this._envelope.to = [];
for (let recipient of recipients) {
if (!recipient) {
// This happens when nsISmtpService.sendMailMessage() is called with
// recipients without @, for example in test_sendMailAddressIDN.js.
continue;
}
let lastAt = null;
let firstInvalid = null;
for (let i = 0; i < recipient.length; i++) {
@ -232,7 +237,7 @@ export class SmtpClient {
break;
}
}
if (!recipient || firstInvalid != null) {
if (firstInvalid != null) {
if (!lastAt) {
// Invalid char found in the localpart, throw error until we implement RFC 6532.
this._onNsError(MsgUtils.NS_ERROR_ILLEGAL_LOCALPART, recipient);

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

@ -18,6 +18,7 @@ var kToValidACE = "to@xn--vlid-loa.foo.invalid";
var kToInvalid = "b\u00F8rken.to@invalid.foo.invalid";
var kToInvalidWithoutDomain = "b\u00F8rken.to";
var NS_ERROR_ILLEGAL_LOCALPART = 0x80553139;
var NS_MSG_NO_RECIPIENTS = 0x805530df;
// for alertTestUtils.js
let resolveAlert;
@ -28,11 +29,14 @@ function alertPS(parent, aDialogText, aText) {
var expectedAlertMessage =
composeProps.GetStringFromName("sendFailed") +
"\n" +
composeProps
.GetStringFromName("errorIllegalLocalPart2")
// Without the domain, we currently don't display any name in the
// message part.
.replace("%s", test == kToInvalidWithoutDomain ? "" : test);
composeProps.GetStringFromName(
test == kToInvalidWithoutDomain
? "noRecipients"
: "errorIllegalLocalPart2"
);
if (test != kToInvalidWithoutDomain) {
expectedAlertMessage = expectedAlertMessage.replace("%s", test);
}
// we should only get here for the kToInvalid test case
Assert.equal(aText, expectedAlertMessage);
@ -70,7 +74,12 @@ MsgSendListener.prototype = {
// Compare data file to what the server received
Assert.equal(this.originalData, server._daemon.post);
} else {
Assert.equal(aStatus, NS_ERROR_ILLEGAL_LOCALPART);
Assert.equal(
aStatus,
test == kToInvalidWithoutDomain
? NS_MSG_NO_RECIPIENTS
: NS_ERROR_ILLEGAL_LOCALPART
);
do_check_transaction(server.playTransaction(), ["EHLO test"]);
// Local address (before the @) has non-ascii char(s) or the @ is
// missing from the address. An alert is triggered after the EHLO is