Bug 1514951 - Fix filter creation from subject header. r=arshad
--- a/mail/base/content/mainPopupSet.inc
+++ b/mail/base/content/mainPopupSet.inc
@@ -1199,17 +1199,17 @@
tooltiptext="©Cmd.label;"
oncommand="Cc['@mozilla.org/widget/clipboardhelper;1']
.getService(Ci.nsIClipboardHelper)
.copyString(window.getSelection().isCollapsed ?
document.popupNode.textContent :
window.getSelection().toString());"/>
<menuitem id="createFilterFromMenuItem" label="&CreateFilterFrom.label;"
accesskey="&CreateFilterFrom.accesskey;"
- oncommand="CreateFilter(this.parentNode.triggerNode.parentNode, gMessageDisplay.displayedMessage)"
+ oncommand="CreateFilter(document.popupNode, gMessageDisplay.displayedMessage)"
observes="cmd_createFilterFromPopup"/>
</menupopup>
<!-- "Please keep all items and separators up to date in nsContextMenu.js when making changes here" -->
<menupopup id="mailContext"
pagemenu="start"
onpopupshowing="return fillMailContextMenu(event);"
onpopuphiding="mailContextOnPopupHiding(event);">
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -160,17 +160,20 @@ function createHeaderEntry(prefix, heade
this.outputFunction = headerListInfo.outputFunction;
else
this.outputFunction = updateHeaderValue;
// Stash this so that the <mail-multi-emailheaderfield/> binding can
// later attach it to any <mail-emailaddress> tags it creates for later
// extraction and use by UpdateEmailNodeDetails.
this.enclosingBox.headerName = headerListInfo.name;
-
+ // Set the headerName attribute for the value nodes too.
+ this.enclosingBox.querySelectorAll(".headerValue").forEach(e => {
+ e.setAttribute("headerName", headerListInfo.name);
+ });
}
function initializeHeaderViewTables() {
// Iterate over each header in our header list arrays and create header entries
// for each one. These header entries are then stored in the appropriate header
// table.
for (let header of gExpandedHeaderList) {
gExpandedHeaderView[header.name] = new createHeaderEntry("expanded", header);
@@ -1582,29 +1585,36 @@ function CopyEmailNewsAddress(addressNod
addressNode.getAttribute("newsgroup");
clipboard.copyString(address);
}
/**
* Causes the filter dialog to pop up, prefilled for the specified e-mail
* address or header value.
*
- * @param aHeaderNode A node which has an "emailAddress" attribute
- * or a "headerName" attribute.
+ * @param aHeaderNode Node for which to create the filter. This can be a node
+ * in an mail-emailaddress element, or a node with just
+ * textual data, like Subject or Date.
* @param aMessage Optional nsIMsgHdr of the message from which the values
* are taken. Will be used to preselect its folder in the
* filter list.
*/
function CreateFilter(aHeaderNode, aMessage) {
- aHeaderNode = aHeaderNode.closest("mail-emailaddress");
- let nodeIsAddress = aHeaderNode.hasAttribute("emailAddress");
- let nodeValue = nodeIsAddress ? aHeaderNode.getAttribute("emailAddress") :
- aHeaderNode.textContent;
+ let addressNode = aHeaderNode.closest("mail-emailaddress");
+ let value;
+ let name;
+ if (addressNode) {
+ name = addressNode.getAttribute("headerName");
+ value = addressNode.getAttribute("emailAddress");
+ } else {
+ name = aHeaderNode.getAttribute("headerName");
+ value = aHeaderNode.textContent;
+ }
let folder = aMessage ? aMessage.folder : null;
- top.MsgFilters(nodeValue, folder, aHeaderNode.getAttribute("headerName"));
+ top.MsgFilters(value, folder, name);
}
/**
* Get the newsgroup server corresponding to the currently selected message.
*
* @return nsISubscribableServer for the newsgroup, or null
*/
function GetNewsgroupServer() {