|
|
|
@ -45,6 +45,7 @@
|
|
|
|
|
#include <boost/assign.hpp>
|
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
|
|
|
|
|
|
#include "version.hpp"
|
|
|
|
|
#include "kazDebug.hpp"
|
|
|
|
|
#include "kazMisc.hpp"
|
|
|
|
|
#include "SizeArg.hpp"
|
|
|
|
@ -62,11 +63,10 @@ static const string CID ("cid:");
|
|
|
|
|
// "l=/" => v1 compatibility
|
|
|
|
|
static const regex archiveURLSignature (".*(([&?]g=)|([&?]l=/)).*");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const string KAZ_PLAIN_HR ("______________________________________________________________________________");
|
|
|
|
|
static const string KAZ_PLAIN_START ("~~ PJ-KAZ !"); // don't end whith space
|
|
|
|
|
static const string KAZ_PLAIN_STOP (KAZ_PLAIN_START+" ~~\n\n");
|
|
|
|
|
static const string KAZ_PLAIN_DONT_TOUCH ("(conservez cette partie intacte dans votre réponse si vous voulez transmettre les documents précédents)");
|
|
|
|
|
static const string KAZ_PLAIN_DONT_TOUCH ("(conservez cette partie intacte dans votre réponse si vous voulez transmettre les documents précédents (version "+LAST_VERSION_NUM+"))");
|
|
|
|
|
static const string KAZ_PLAIN_WARNING ("Attention : Kaz a dépollué ce message. Les pièces jointes ont été retirées et placées dans un dépôt provisoire. "
|
|
|
|
|
"Elles seront automatiquement supprimées dans 1 mois. "
|
|
|
|
|
"Si elles sont importantes et que vous souhaitez les conserver, vous devez utiliser les liens ci-dessous. "
|
|
|
|
@ -94,7 +94,7 @@ static const string KAZ_HTML_TAG ("<!--KAZ"); // don't end whith space
|
|
|
|
|
static const string KAZ_HTML_START (KAZ_HTML_TAG+" START-->");
|
|
|
|
|
static const string KAZ_HTML_STOP (KAZ_HTML_TAG+" STOP-->");
|
|
|
|
|
// Textes précédents encodés en SGML
|
|
|
|
|
static const string KAZ_HTML_DONT_TOUCH ("(conservez cette partie intacte dans votre réponse si vous voulez transmettre les documents précédents)");
|
|
|
|
|
static const string KAZ_HTML_DONT_TOUCH ("(conservez cette partie intacte dans votre réponse si vous voulez transmettre les documents précédents (version "+LAST_VERSION_NUM+"))");
|
|
|
|
|
static const string KAZ_HTML_DOWLOAD_ONE ("Vos pièces jointes sont à télécharger individuellement ici :");
|
|
|
|
|
static const string KAZ_HTML_DOWLOAD_OTHER ("(Contenu dans des messages précédents)");
|
|
|
|
|
static const string KAZ_HTML_DOWLOAD_ALL ("Vous pouvez télécharger l'ensemble dans une archive là :");
|
|
|
|
@ -112,8 +112,8 @@ vector <string>
|
|
|
|
|
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
|
|
|
|
|
|
|
|
|
// ================================================================================
|
|
|
|
|
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\r\n");
|
|
|
|
|
const string MainAttachment::templatePlainAllLink ("\r\n * "+KAZ_PLAIN_DOWLOAD_ALL+" <"+TMPL_DOWNLOAD+">\r\n");
|
|
|
|
|
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\n");
|
|
|
|
|
const string MainAttachment::templatePlainAllLink ("\n * "+KAZ_PLAIN_DOWLOAD_ALL+" <"+TMPL_DOWNLOAD+">\n");
|
|
|
|
|
|
|
|
|
|
const string MainAttachment::templateHtmlHeader (KAZ_HTML_START+"<p style=\"clear: left; padding: 1pc 0 0 0; font-size:10px; color:#969696;\">"+KAZ_PLAIN_START+"</p><hr>\n"
|
|
|
|
|
"<div class=\"kaz\">"
|
|
|
|
@ -257,10 +257,10 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plain = "\r\n"+KAZ_PLAIN_START+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_DONT_TOUCH+"\r\n\r\n"+KAZ_PLAIN_DOWLOAD_ONE+"\r\n"+plainNewLinks;
|
|
|
|
|
plain = "\n"+KAZ_PLAIN_START+"\n\n"+KAZ_PLAIN_HR+"\n"+KAZ_PLAIN_DONT_TOUCH+"\n\n"+KAZ_PLAIN_DOWLOAD_ONE+"\n"+plainNewLinks;
|
|
|
|
|
html = templateHtmlHeader+htmlNewLinks;
|
|
|
|
|
if (previousLinks.size ()) {
|
|
|
|
|
plain += "\r\n"+KAZ_PLAIN_DOWLOAD_OTHER+"\r\n"+plainOldLinks;
|
|
|
|
|
plain += "\n"+KAZ_PLAIN_DOWLOAD_OTHER+"\n"+plainOldLinks;
|
|
|
|
|
html += templateHtmlOtherLink+htmlOldLinks;
|
|
|
|
|
}
|
|
|
|
|
if (linkCount > 1 && archiveDownloadURL.length ()) {
|
|
|
|
@ -271,8 +271,8 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|
|
|
|
replaceAll (allHtmlLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
|
|
|
|
html += allHtmlLinks;
|
|
|
|
|
}
|
|
|
|
|
html += templateHtmlFooter+"\r\n";
|
|
|
|
|
plain += "\r\n\r\n"+KAZ_WEB_SITE+"\r\n\r\n"+KAZ_PLAIN_WARNING+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_STOP+"\r\n";
|
|
|
|
|
html += templateHtmlFooter+"\n";
|
|
|
|
|
plain += "\n\n"+KAZ_WEB_SITE+"\n\n"+KAZ_PLAIN_WARNING+"\n"+KAZ_PLAIN_HR+"\n"+KAZ_PLAIN_STOP+"\n";
|
|
|
|
|
// & => & done
|
|
|
|
|
LOG ("plain: " << plain);
|
|
|
|
|
LOG ("html: " << html);
|
|
|
|
@ -288,7 +288,7 @@ MainAttachment::addPrevious (const string &href, const string &name, const bool
|
|
|
|
|
if (oldVal.length () && name.length () && !trust)
|
|
|
|
|
return;
|
|
|
|
|
previousLinks.erase (href);
|
|
|
|
|
previousLinks [href] = regex_replace (name, regex (R"([\t\r\n\"]+|(\\\")|(>\s*))"), "");
|
|
|
|
|
previousLinks [href] = regex_replace (name, regex (R"([\t\n\"]+|(\\\")|(>\s*))"), "");
|
|
|
|
|
LOG ("inserted: " << href << ": " << previousLinks[href]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -380,6 +380,7 @@ MainAttachment::extractPreviousKAZ (string &extractedPlainKAZ, string &extracted
|
|
|
|
|
if (textProp.empty ())
|
|
|
|
|
return;
|
|
|
|
|
string content (attach.getContent (mbox));
|
|
|
|
|
replaceAll (content, "&", "&");
|
|
|
|
|
if (textProp == PLAIN) {
|
|
|
|
|
LOG (PLAIN);
|
|
|
|
|
extractedPlainKAZ += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
|
|
|
@ -389,7 +390,6 @@ MainAttachment::extractPreviousKAZ (string &extractedPlainKAZ, string &extracted
|
|
|
|
|
string section = attach.getSection (content, KAZ_HTML_START, KAZ_HTML_STOP);
|
|
|
|
|
section += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
|
|
|
|
// update href from HTML attachments
|
|
|
|
|
replaceAll (section, "&", "&");
|
|
|
|
|
extractedHtmlKAZ += section;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|