зеркало из https://github.com/mozilla/pjs.git
Bug 132257 Inserting a link to a [network][image] file into a message inserts the physical file!
p=me/ducarroz r=daniel/neil sr=bienvenu
This commit is contained in:
Родитель
abf6139247
Коммит
fb34fa5ddf
|
@ -3847,22 +3847,11 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
|
|||
node->GetNodeName(tagName);
|
||||
ToLowerCase(tagName);
|
||||
|
||||
// See if it's an image or an embed
|
||||
if (tagName.EqualsLiteral("img") || tagName.EqualsLiteral("embed"))
|
||||
// See if it's an image or an embed and also include all links.
|
||||
// Let mail decide which link to send or not
|
||||
if (tagName.EqualsLiteral("img") || tagName.EqualsLiteral("embed") ||
|
||||
tagName.EqualsLiteral("a"))
|
||||
(*aNodeList)->AppendElement(node);
|
||||
else if (tagName.EqualsLiteral("a"))
|
||||
{
|
||||
// Only include links if they're links to file: URLs
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor (do_QueryInterface(content));
|
||||
if (anchor)
|
||||
{
|
||||
nsAutoString href;
|
||||
if (NS_SUCCEEDED(anchor->GetHref(href)))
|
||||
if (StringBeginsWith(href, NS_LITERAL_STRING("file:"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
(*aNodeList)->AppendElement(node);
|
||||
}
|
||||
}
|
||||
else if (tagName.EqualsLiteral("body"))
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
|
||||
|
|
|
@ -59,11 +59,12 @@
|
|||
tooltiptext="&locationEditField.tooltip;"
|
||||
/>
|
||||
<textbox id="srcInput" oninput="ChangeImageSrc();" tabindex="1" class="uri-element"/>
|
||||
<hbox>
|
||||
<hbox id="MakeRelativeHbox">
|
||||
<checkbox
|
||||
id = "MakeRelativeCheckbox"
|
||||
for = "srcInput"
|
||||
tabindex="2"/>
|
||||
<!-- mail compose will insert custom item here defined in mailComposeEditorOverlay.xul -->
|
||||
<spacer flex="1"/>
|
||||
<!-- from EdDialogOverlay.xul -->
|
||||
<button id="ChooseFile" tabindex="3"/>
|
||||
|
|
|
@ -69,8 +69,9 @@
|
|||
</vbox>
|
||||
</groupbox>
|
||||
|
||||
<groupbox><caption label="&LinkURLBox.label;"/>
|
||||
<groupbox id="LinkURLBox"><caption label="&LinkURLBox.label;"/>
|
||||
<vbox id="LinkLocationBox"/>
|
||||
<!-- mail compose will insert custom item here defined in mailComposeEditorOverlay.xul -->
|
||||
</groupbox>
|
||||
</vbox>
|
||||
<!-- from EdDialogOverlay -->
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
messenger.jar:
|
||||
% overlay chrome://editor/content/EdImageOverlay.xul chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul
|
||||
% overlay chrome://editor/content/EdLinkProps.xul chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul
|
||||
* content/messenger/messengercompose/messengercompose.xul (content/messengercompose.xul)
|
||||
* content/messenger/messengercompose/MsgComposeCommands.js (content/MsgComposeCommands.js)
|
||||
* content/messenger/messengercompose/addressingWidgetOverlay.js (content/addressingWidgetOverlay.js)
|
||||
|
@ -9,6 +11,7 @@ messenger.jar:
|
|||
content/messenger/messengercompose/sendProgress.js (/mailnews/compose/resources/content/sendProgress.js)
|
||||
content/messenger/messengercompose/MsgAttachPage.xul (/mailnews/compose/resources/content/MsgAttachPage.xul)
|
||||
content/messenger/messengercompose/MsgAttachPage.js (/mailnews/compose/resources/content/MsgAttachPage.js)
|
||||
content/messenger/messengercompose/mailComposeEditorOverlay.xul (/mailnews/compose/resources/content/mailComposeEditorOverlay.xul)
|
||||
|
||||
comm.jar:
|
||||
+ content/editor/EdSpellCheck.js (content/EdSpellCheck.js)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<!ENTITY attachImageSource.label "Attach this image to the message">
|
||||
<!ENTITY attachImageSource.accesskey "s">
|
||||
|
||||
<!ENTITY attachLinkSource.label "Attach the source of this link to the message">
|
||||
<!ENTITY attachLinkSource.accesskey "s">
|
|
@ -100,6 +100,7 @@
|
|||
locale/@AB_CD@/messenger/messengercompose/askSendFormat.dtd (%chrome/messenger/messengercompose/askSendFormat.dtd)
|
||||
locale/@AB_CD@/messenger/messengercompose/sendProgress.dtd (%chrome/messenger/messengercompose/sendProgress.dtd)
|
||||
locale/@AB_CD@/messenger/messengercompose/composeMsgs.properties (%chrome/messenger/messengercompose/composeMsgs.properties)
|
||||
locale/@AB_CD@/messenger/messengercompose/mailComposeEditorOverlay.dtd (%chrome/messenger/messengercompose/mailComposeEditorOverlay.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/preferences.dtd (%chrome/messenger/preferences/preferences.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/general.dtd (%chrome/messenger/preferences/general.dtd)
|
||||
locale/@AB_CD@/messenger/preferences/display.dtd (%chrome/messenger/preferences/display.dtd)
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
<RDF:li resource="chrome://messenger/content/addressbook/abSelectAddressesDialog.xul"/>
|
||||
<RDF:li resource="chrome://editor/content/editor.xul"/>
|
||||
<RDF:li resource="chrome://editor/content/editorTasksOverlay.xul"/>
|
||||
<RDF:li resource="chrome://editor/content/EdImageOverlay.xul"/>
|
||||
<RDF:li resource="chrome://editor/content/EdLinkProps.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
|
||||
|
@ -93,5 +95,13 @@
|
|||
<RDF:Seq about="chrome://editor/content/editor.xul">
|
||||
<RDF:li>chrome://messenger/content/mailEditorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://editor/content/EdImageOverlay.xul">
|
||||
<RDF:li>chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://editor/content/EdLinkProps.xul">
|
||||
<RDF:li>chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is SeaMonkey Internet Suite code.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Jean-Francois Ducarroz.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Ian Neal (iann_bugzilla@arlen.demon.co.uk)
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/mailComposeEditorOverlay.dtd" >
|
||||
|
||||
<overlay id="mailComposeEditorOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
|
||||
var gMsgCompProcessLink = false;
|
||||
var gMsgCompInputElement = null;
|
||||
var gMsgCompPrevInputValue = null;
|
||||
var gMsgCompPrevMozDoNotSendAttribute;
|
||||
var gMsgCompAttachSourceElement = null;
|
||||
var gMOZDONOTSEND = "moz-do-not-send";
|
||||
var gMsgCompPrefs = null;
|
||||
|
||||
function OnLoadOverlay()
|
||||
{
|
||||
gMsgCompAttachSourceElement = document.getElementById("AttachSourceToMail");
|
||||
var editor = GetCurrentEditor();
|
||||
if (gMsgCompAttachSourceElement && editor &&
|
||||
(editor.flags & Components.interfaces.nsIPlaintextEditor.eEditorMailMask))
|
||||
{
|
||||
SetRelativeCheckbox = function() { SetAttachCheckbox();};
|
||||
//initialize the AttachSourceToMail checkbox
|
||||
gMsgCompAttachSourceElement.hidden = false;
|
||||
|
||||
switch (document.documentElement.id)
|
||||
{
|
||||
case "imageDlg":
|
||||
gMsgCompInputElement = gDialog.srcInput;
|
||||
gMsgCompProcessLink = false;
|
||||
break;
|
||||
case "linkDlg" :
|
||||
gMsgCompInputElement = gDialog.hrefInput;
|
||||
gMsgCompProcessLink = true;
|
||||
break;
|
||||
}
|
||||
if (gMsgCompInputElement)
|
||||
{
|
||||
SetAttachCheckbox();
|
||||
gMsgCompPrevMozDoNotSendAttribute = globalElement.getAttribute(gMOZDONOTSEND)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener("load", OnLoadOverlay, false);
|
||||
|
||||
function SetAttachCheckbox()
|
||||
{
|
||||
var resetCheckbox = false;
|
||||
var mozDoNotSend = globalElement.getAttribute(gMOZDONOTSEND);
|
||||
|
||||
//In case somebody played with the advanced property and changed the moz-do-not-send attribute
|
||||
if (mozDoNotSend != gMsgCompPrevMozDoNotSendAttribute)
|
||||
{
|
||||
gMsgCompPrevMozDoNotSendAttribute = mozDoNotSend;
|
||||
resetCheckbox = true;
|
||||
}
|
||||
|
||||
// Has the URL changed
|
||||
if (gMsgCompInputElement && gMsgCompInputElement.value != gMsgCompPrevInputValue)
|
||||
{
|
||||
gMsgCompPrevInputValue = gMsgCompInputElement.value;
|
||||
resetCheckbox = true;
|
||||
}
|
||||
|
||||
if (gMsgCompInputElement && resetCheckbox)
|
||||
{
|
||||
// Here is the rule about how to set the checkbox Attach Source To Message:
|
||||
// if the attribute moz-do-not-send has not been set, we look at the scheme of the url
|
||||
// and at some pref to decide what is the best for the user. Else if it is set to true,
|
||||
// the checkbox is unchecked else is checked.
|
||||
var attach = true;
|
||||
if (mozDoNotSend == null)
|
||||
{
|
||||
// We haven't yet set the moz-do-not-send attribute, let's figure out the best setting
|
||||
// the rule should be in sync with to the one in nsMsgComposeAndSend::GetEmbeddedObjectInfo
|
||||
|
||||
if (gMsgCompProcessLink)
|
||||
{
|
||||
//is it a Windows remote file?
|
||||
if (/^\s*file:\/\/\/\/\//i.test(gMsgCompInputElement.value))
|
||||
{
|
||||
try {
|
||||
if (!gMsgCompPrefs)
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
gMsgCompPrefs = prefService.getBranch(null);
|
||||
}
|
||||
if (gMsgCompPrefs && gMsgCompPrefs.getBoolPref("mail.compose.dont_attach_source_of_local_network_links"))
|
||||
attach = false;
|
||||
} catch(ex) {};
|
||||
}
|
||||
//is it not a file: location at all?
|
||||
else if (!/^\s*file:\/\//i.test(gMsgCompInputElement.value))
|
||||
attach = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
attach = (mozDoNotSend != "true");
|
||||
|
||||
gMsgCompAttachSourceElement.checked = attach;
|
||||
}
|
||||
}
|
||||
|
||||
function DoAttachSourceCheckbox()
|
||||
{
|
||||
gMsgCompPrevMozDoNotSendAttribute = (!gMsgCompAttachSourceElement.checked).toString();
|
||||
globalElement.setAttribute(gMOZDONOTSEND, gMsgCompPrevMozDoNotSendAttribute)
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<hbox id="MakeRelativeHbox">
|
||||
<checkbox id="AttachSourceToMail" hidden="true"
|
||||
label="&attachImageSource.label;" accesskey="&attachImageSource.accesskey;"
|
||||
insertafter="MakeRelativeCheckbox" oncommand="DoAttachSourceCheckbox()"/>
|
||||
</hbox>
|
||||
|
||||
<groupbox id="LinkURLBox">
|
||||
<checkbox id="AttachSourceToMail" hidden="true"
|
||||
label="&attachLinkSource.label;" accesskey="&attachLinkSource.accesskey;"
|
||||
insertafter="LinkLocationBox" oncommand="DoAttachSourceCheckbox()"/>
|
||||
</groupbox>
|
||||
|
||||
</overlay>
|
|
@ -118,6 +118,9 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
|||
#define PREF_MAIL_STRICTLY_MIME "mail.strictly_mime"
|
||||
#define PREF_MAIL_MESSAGE_WARNING_SIZE "mailnews.message_warning_size"
|
||||
#define PREF_MAIL_COLLECT_EMAIL_ADDRESS_OUTGOING "mail.collect_email_address_outgoing"
|
||||
#define PREF_MAIL_DONT_ATTACH_SOURCE "mail.compose.dont_attach_source_of_local_network_links"
|
||||
|
||||
#define ATTR_MOZ_DO_NOT_SEND "moz-do-not-send"
|
||||
|
||||
enum { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) };
|
||||
|
||||
|
@ -1439,22 +1442,29 @@ nsMsgComposeAndSend::GetEmbeddedObjectInfo(nsIDOMNode *node, nsMsgAttachmentData
|
|||
NS_ENSURE_ARG_POINTER(attachment);
|
||||
NS_ENSURE_ARG_POINTER(acceptObject);
|
||||
|
||||
// GetEmbeddedObjectInfo will determine if we need to attach the source of the embedded object with the message
|
||||
// The decision is made automatically unless the attribute moz-do-not-send has been set to true or false
|
||||
// The default rule is that all image and anchor objects are attached as well link to a local file
|
||||
nsresult rv;
|
||||
|
||||
// Reset this structure to null!
|
||||
memset(attachment, 0, sizeof(nsMsgAttachmentData));
|
||||
*acceptObject = PR_FALSE;
|
||||
|
||||
// Check if the object has an moz-do-not-send attribute set. If it's the case,
|
||||
// we must ignore it
|
||||
// Check if the object has a moz-do-not-send attribute set. If it's true,
|
||||
// we must ignore it, if false set forceToBeAttached to be true.
|
||||
|
||||
PRBool forceToBeAttached = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(node);
|
||||
if (domElement)
|
||||
{
|
||||
nsAutoString attributeValue;
|
||||
if (NS_SUCCEEDED(domElement->GetAttribute(NS_LITERAL_STRING("moz-do-not-send"), attributeValue)))
|
||||
if (NS_SUCCEEDED(domElement->GetAttribute(NS_LITERAL_STRING(ATTR_MOZ_DO_NOT_SEND), attributeValue)))
|
||||
{
|
||||
if (attributeValue.LowerCaseEqualsLiteral("true"))
|
||||
return NS_OK;
|
||||
forceToBeAttached = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, we know the types of objects this node can be, so we will do
|
||||
|
@ -1601,6 +1611,28 @@ nsMsgComposeAndSend::GetEmbeddedObjectInfo(nsIDOMNode *node, nsMsgAttachmentData
|
|||
rv = aLocalFile->IsFile(&isAValidFile);
|
||||
if (NS_FAILED(rv))
|
||||
isAValidFile = PR_FALSE;
|
||||
else
|
||||
{
|
||||
if (anchor)
|
||||
{
|
||||
// One more test, if the anchor points to a local network server, let's check what the pref
|
||||
// mail.compose.dont_attach_source_of_local_network_links tells us to do.
|
||||
nsCAutoString urlSpec;
|
||||
rv = attachment->url->GetSpec(urlSpec);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (StringBeginsWith(urlSpec, NS_LITERAL_CSTRING("file://///")))
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (pPrefBranch)
|
||||
{
|
||||
PRBool dontSend = PR_FALSE;
|
||||
rv = pPrefBranch->GetBoolPref(PREF_MAIL_DONT_ATTACH_SOURCE, &dontSend);
|
||||
if (dontSend)
|
||||
isAValidFile = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1608,6 +1640,12 @@ nsMsgComposeAndSend::GetEmbeddedObjectInfo(nsIDOMNode *node, nsMsgAttachmentData
|
|||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else //not a file:// url
|
||||
{
|
||||
//if this is an anchor, don't attach remote file unless we have been forced to do it
|
||||
if (anchor && !forceToBeAttached)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*acceptObject = PR_TRUE;
|
||||
return NS_OK;
|
||||
|
|
|
@ -181,6 +181,7 @@ messenger.jar:
|
|||
content/messenger/messengercompose/MsgAttachPage.xul (compose/resources/content/MsgAttachPage.xul)
|
||||
content/messenger/messengercompose/MsgAttachPage.js (compose/resources/content/MsgAttachPage.js)
|
||||
content/messenger/messengercompose/mailComposeExtrasOverlay.xul (compose/resources/content/mailComposeExtrasOverlay.xul)
|
||||
content/messenger/messengercompose/mailComposeEditorOverlay.xul (compose/resources/content/mailComposeEditorOverlay.xul)
|
||||
content/messenger/importDialog.js (import/resources/content/importDialog.js)
|
||||
content/messenger/importDialog.xul (import/resources/content/importDialog.xul)
|
||||
content/messenger/fieldMapImport.xul (import/resources/content/fieldMapImport.xul)
|
||||
|
@ -248,6 +249,7 @@ en-US.jar:
|
|||
locale/en-US/messenger/messengercompose/addressingWidgetOverlay.dtd (compose/resources/locale/en-US/addressingWidgetOverlay.dtd)
|
||||
locale/en-US/messenger/messengercompose/askSendFormat.dtd (compose/resources/locale/en-US/askSendFormat.dtd)
|
||||
locale/en-US/messenger/messengercompose/sendProgress.dtd (compose/resources/locale/en-US/sendProgress.dtd)
|
||||
locale/en-US/messenger/messengercompose/mailComposeEditorOverlay.dtd (compose/resources/locale/en-US/mailComposeEditorOverlay.dtd)
|
||||
locale/en-US/messenger/messengercompose/MsgAttachPage.dtd (compose/resources/locale/en-US/MsgAttachPage.dtd)
|
||||
locale/en-US/messenger/messengercompose/composeMsgs.properties (compose/resources/locale/en-US/composeMsgs.properties)
|
||||
locale/en-US/messenger/imapMsgs.properties (imap/resources/locale/en-US/imapMsgs.properties)
|
||||
|
|
|
@ -655,6 +655,10 @@ pref("msgcompose.background_color", "#FFFFFF");
|
|||
// to prevent some mail server to disclose the bcc recipients
|
||||
pref("mail.compose.add_undisclosed_recipients", true);
|
||||
|
||||
// Set this preference to true to tell mail not to attach the source of a link to a local
|
||||
// network file (file://///<network name>/<path>/<file name>). Windows only
|
||||
pref("mail.compose.dont_attach_source_of_local_network_links", false);
|
||||
|
||||
// these prefs (in minutes) are here to help QA test this feature
|
||||
// "mail.purge.min_delay", never purge a junk folder more than once every 480 minutes (60 mins/hour * 8 hours)
|
||||
// "mail.purge.timer_interval", fire the purge timer every 5 minutes, starting 5 minutes after we load accounts
|
||||
|
|
Загрузка…
Ссылка в новой задаче