Bug 1587587 - Show an alert if a new mailing list name won't work. r=darktrojan a=jorgk
authorPaul Morris <paul@thunderbird.net>
Sat, 12 Oct 2019 23:32:03 +0200
changeset 36695 2ecd5527f4bd2043d89e37010bd5ab952cc00e60
parent 36694 1f623ce59de43a442e87cd9ea2e2757d40be6e93
child 36696 08f3db86ac9aa66ba1dfafb2dfdb70819c210255
push id394
push userclokep@gmail.com
push dateMon, 21 Oct 2019 20:22:01 +0000
reviewersdarktrojan, jorgk
bugs1587587
Bug 1587587 - Show an alert if a new mailing list name won't work. r=darktrojan a=jorgk
mail/locales/en-US/chrome/messenger/addressbook/addressBook.properties
mailnews/addrbook/content/abMailListDialog.js
--- a/mail/locales/en-US/chrome/messenger/addressbook/addressBook.properties
+++ b/mail/locales/en-US/chrome/messenger/addressbook/addressBook.properties
@@ -1,16 +1,18 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # The following are used by the Mailing list dialog.
 # LOCALIZATION NOTE (mailingListTitleEdit): %S will be replaced by the Mailing List's display name.
 mailingListTitleEdit=Edit %S
 emptyListName=You must enter a list name.
+badListNameCharacters=A list name cannot contain any of the following characters: < > ; , "
+badListNameSpaces=A list name cannot contain multiple adjacent spaces.
 lastFirstFormat=%S, %S
 firstLastFormat=%S %S
 
 allAddressBooks=All Address Books
 
 newContactTitle=New Contact
 # %S will be the contact's display name
 newContactTitleWithDisplayName=New Contact for %S
--- a/mailnews/addrbook/content/abMailListDialog.js
+++ b/mailnews/addrbook/content/abMailListDialog.js
@@ -57,16 +57,28 @@ function mailingListExists(listname) {
 function updateMailList(mailList, isNewList) {
   let listname = document.getElementById("ListName").value.trim();
 
   if (listname.length == 0) {
     alert(gAddressBookBundle.getString("emptyListName"));
     return false;
   }
 
+  if (listname.match("  ")) {
+    alert(gAddressBookBundle.getString("badListNameSpaces"));
+    return false;
+  }
+
+  for (let char of ',;"<>') {
+    if (listname.includes(char)) {
+      alert(gAddressBookBundle.getString("badListNameCharacters"));
+      return false;
+    }
+  }
+
   let canonicalNewListName = listname.toLowerCase();
   let canonicalOldListName = gOldListName.toLowerCase();
   if (isNewList || canonicalOldListName != canonicalNewListName) {
     if (mailingListExists(canonicalNewListName)) {
       return false;
     }
   }