[Libreoffice-bugs] [Bug 126263] New: sending emails with attachments via "com.sun.star.system.SimpleSystemMail" can cause data loss
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Sun Jul 7 08:19:26 UTC 2019
https://bugs.documentfoundation.org/show_bug.cgi?id=126263
Bug ID: 126263
Summary: sending emails with attachments via
"com.sun.star.system.SimpleSystemMail" can cause data
loss
Product: LibreOffice
Version: 6.1.6.3 release
Hardware: All
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: framework
Assignee: libreoffice-bugs at lists.freedesktop.org
Reporter: oliver.brinzing at gmx.de
Created attachment 152612
--> https://bugs.documentfoundation.org/attachment.cgi?id=152612&action=edit
mail demo basic
sending emails with attachments via "com.sun.star.system.SimpleSystemMail" can
cause data loss, if file paths instead of file urls are added.
> void setAttachement([in] sequence< string > aAttachement)
> raises (::com::sun::star::lang::IllegalArgumentException)
> aAttachement Sets a sequence of file URLs specifying the files that should
> be attached to the mail. The given file URLs must conform to Rfc1738.
> The method does not check if the specified file or files really exist.
steps to reproduce:
- add some pdf files: a.pdf, b.pdf, c.pdf, d.pdf to LO working directory
- run attached macro (-> mail_demo.bas)
-> b.pdf is removed, cause it is added as file path
root cause:
"senddoc.exe" tries to copy attachments to a temp dir before calling email
client. these files are removed on exit (). but if copy fails (e.g. attachment
is a file path instead of a file url) it uses the original file path.
expectation:
either setAttachment() throws an exception if a file path (or invalid url) is
added or "senddoc.exe" does not remove original file.
smplmailclient.cxx:
OUString CSmplMailClient::CopyAttachment(const OUString& sOrigAttachURL,
OUString& sUserVisibleName)
{
// We do two things here:
// 1. Make the attachment temporary filename to not contain any fancy
characters possible in
// original filename, that could confuse mailer, and extract the original
filename to explicitly
// define it;
// 2. Allow the copied files be outside of the session's temporary
directory, and thus not be
// removed in Desktop::RemoveTemporaryDirectory() if soffice process gets
closed before the
// mailer finishes using them.
maAttachmentFiles.emplace_back(std::make_unique<utl::TempFile>(&GetBaseTempDirURL()));
maAttachmentFiles.back()->EnableKillingFile();
INetURLObject aFilePathObj(maAttachmentFiles.back()->GetURL());
OUString sNewAttachmentURL =
aFilePathObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
if (osl::File::copy(sOrigAttachURL, sNewAttachmentURL) ==
osl::FileBase::RC::E_None)
{
INetURLObject url(sOrigAttachURL,
INetURLObject::EncodeMechanism::WasEncoded);
sUserVisibleName = url.getName(INetURLObject::LAST_SEGMENT, true,
INetURLObject::DecodeMechanism::WithCharset);
}
else
{
// Failed to copy original; the best effort is to use original file. It
is possible that
// the file gets deleted before used in spawned process; but let's
hope... the worst thing
// is the absent attachment file anyway.
sNewAttachmentURL = sOrigAttachURL;
maAttachmentFiles.pop_back();
}
return sNewAttachmentURL;
}
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20190707/143943ff/attachment.html>
More information about the Libreoffice-bugs
mailing list