From db829f92cb5c315821ab47013ca02ba84290d5db Mon Sep 17 00:00:00 2001 From: "bugzilla%arlen.demon.co.uk" Date: Sat, 29 Jul 2006 05:44:30 +0000 Subject: [PATCH] Bug 290881 Implement Add to Address book / Compose mail to context menus p=me r=mnyromyr sr=neil.parkwaycc.co.uk git-svn-id: svn://10.0.0.236/trunk@205874 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/suite/common/nsContextMenu.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mozilla/suite/common/nsContextMenu.js b/mozilla/suite/common/nsContextMenu.js index dbcea756b0c..9310702c809 100644 --- a/mozilla/suite/common/nsContextMenu.js +++ b/mozilla/suite/common/nsContextMenu.js @@ -627,35 +627,30 @@ nsContextMenu.prototype = { saveImageURL( this.imageURL, null, "SaveImageTitle", false, getReferrer(document) ); }, - // Generate email address and put it on clipboard. - copyEmail : function () { - // Copy the comma-separated list of email addresses only. + // Generate email address. + getEmail : function () { + // Get the comma-separated list of email addresses only. // There are other ways of embedding email addresses in a mailto: // link, but such complex parsing is beyond us. - var url = this.linkURL(); - var qmark = url.indexOf( "?" ); var addresses; - - if ( qmark > 7 ) { // 7 == length of "mailto:" - addresses = url.substring( 7, qmark ); - } else { - addresses = url.substr( 7 ); - } - - // Let's try to unescape it using a character set try { + // Let's try to unescape it using a character set var characterSet = this.target.ownerDocument.characterSet; const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"] .getService(Components.interfaces.nsITextToSubURI); + addresses = this.linkURL().match(/^mailto:([^?]+)/)[1]; addresses = textToSubURI.unEscapeURIForUI(characterSet, addresses); } catch(ex) { // Do nothing. } - + return addresses; + }, + // Copy email to clipboard + copyEmail : function () { var clipboard = this.getService( "@mozilla.org/widget/clipboardhelper;1", Components.interfaces.nsIClipboardHelper ); - clipboard.copyString(addresses); + clipboard.copyString(this.getEmail()); }, addBookmark : function() { var docshell = document.getElementById( "content" ).webNavigation;