Bug 1587587 - Show an alert if a new mailing list name won't work. r=darktrojan
authorPaul Morris <paul@thunderbird.net>
Sat, 12 Oct 2019 23:32:03 +0200
changeset 27906 7e9ef7f6158ab14df2c9c439882ff91b0aa2fe47
parent 27905 8f5ce14d70f4ad8d2b22624f2d5e178790e2ca68
child 27907 9ec80cfd971196fa362d4dd15e2506af383f8d58
push id16549
push usermozilla@jorgk.com
push dateSat, 12 Oct 2019 21:58:00 +0000
treeherdercomm-central@9ec80cfd9711 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1587587
Bug 1587587 - Show an alert if a new mailing list name won't work. r=darktrojan
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;
     }
   }