double remove & / display version
This commit is contained in:
parent
8e74856ad2
commit
df7a25d331
0
src/bash/filter.sh
Normal file → Executable file
0
src/bash/filter.sh
Normal file → Executable file
0
src/bash/filterTest.sh
Normal file → Executable file
0
src/bash/filterTest.sh
Normal file → Executable file
@ -45,6 +45,7 @@
|
|||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "version.hpp"
|
||||||
#include "kazDebug.hpp"
|
#include "kazDebug.hpp"
|
||||||
#include "kazMisc.hpp"
|
#include "kazMisc.hpp"
|
||||||
#include "SizeArg.hpp"
|
#include "SizeArg.hpp"
|
||||||
@ -62,11 +63,10 @@ static const string CID ("cid:");
|
|||||||
// "l=/" => v1 compatibility
|
// "l=/" => v1 compatibility
|
||||||
static const regex archiveURLSignature (".*(([&?]g=)|([&?]l=/)).*");
|
static const regex archiveURLSignature (".*(([&?]g=)|([&?]l=/)).*");
|
||||||
|
|
||||||
|
|
||||||
static const string KAZ_PLAIN_HR ("______________________________________________________________________________");
|
static const string KAZ_PLAIN_HR ("______________________________________________________________________________");
|
||||||
static const string KAZ_PLAIN_START ("~~ PJ-KAZ !"); // don't end whith space
|
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_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. "
|
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. "
|
"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. "
|
"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_START (KAZ_HTML_TAG+" START-->");
|
||||||
static const string KAZ_HTML_STOP (KAZ_HTML_TAG+" STOP-->");
|
static const string KAZ_HTML_STOP (KAZ_HTML_TAG+" STOP-->");
|
||||||
// Textes précédents encodés en SGML
|
// 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_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_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à :");
|
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});
|
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\r\n");
|
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\n");
|
||||||
const string MainAttachment::templatePlainAllLink ("\r\n * "+KAZ_PLAIN_DOWLOAD_ALL+" <"+TMPL_DOWNLOAD+">\r\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"
|
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\">"
|
"<div class=\"kaz\">"
|
||||||
@ -257,10 +257,10 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|||||||
return;
|
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;
|
html = templateHtmlHeader+htmlNewLinks;
|
||||||
if (previousLinks.size ()) {
|
if (previousLinks.size ()) {
|
||||||
plain += "\r\n"+KAZ_PLAIN_DOWLOAD_OTHER+"\r\n"+plainOldLinks;
|
plain += "\n"+KAZ_PLAIN_DOWLOAD_OTHER+"\n"+plainOldLinks;
|
||||||
html += templateHtmlOtherLink+htmlOldLinks;
|
html += templateHtmlOtherLink+htmlOldLinks;
|
||||||
}
|
}
|
||||||
if (linkCount > 1 && archiveDownloadURL.length ()) {
|
if (linkCount > 1 && archiveDownloadURL.length ()) {
|
||||||
@ -271,8 +271,8 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|||||||
replaceAll (allHtmlLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
replaceAll (allHtmlLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
||||||
html += allHtmlLinks;
|
html += allHtmlLinks;
|
||||||
}
|
}
|
||||||
html += templateHtmlFooter+"\r\n";
|
html += templateHtmlFooter+"\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";
|
plain += "\n\n"+KAZ_WEB_SITE+"\n\n"+KAZ_PLAIN_WARNING+"\n"+KAZ_PLAIN_HR+"\n"+KAZ_PLAIN_STOP+"\n";
|
||||||
// & => & done
|
// & => & done
|
||||||
LOG ("plain: " << plain);
|
LOG ("plain: " << plain);
|
||||||
LOG ("html: " << html);
|
LOG ("html: " << html);
|
||||||
@ -288,7 +288,7 @@ MainAttachment::addPrevious (const string &href, const string &name, const bool
|
|||||||
if (oldVal.length () && name.length () && !trust)
|
if (oldVal.length () && name.length () && !trust)
|
||||||
return;
|
return;
|
||||||
previousLinks.erase (href);
|
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]);
|
LOG ("inserted: " << href << ": " << previousLinks[href]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +380,7 @@ MainAttachment::extractPreviousKAZ (string &extractedPlainKAZ, string &extracted
|
|||||||
if (textProp.empty ())
|
if (textProp.empty ())
|
||||||
return;
|
return;
|
||||||
string content (attach.getContent (mbox));
|
string content (attach.getContent (mbox));
|
||||||
|
replaceAll (content, "&", "&");
|
||||||
if (textProp == PLAIN) {
|
if (textProp == PLAIN) {
|
||||||
LOG (PLAIN);
|
LOG (PLAIN);
|
||||||
extractedPlainKAZ += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
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);
|
string section = attach.getSection (content, KAZ_HTML_START, KAZ_HTML_STOP);
|
||||||
section += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
section += attach.getSection (content, KAZ_PLAIN_START, KAZ_PLAIN_STOP);
|
||||||
// update href from HTML attachments
|
// update href from HTML attachments
|
||||||
replaceAll (section, "&", "&");
|
|
||||||
extractedHtmlKAZ += section;
|
extractedHtmlKAZ += section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,10 @@
|
|||||||
// knowledge of the CeCILL-B license and that you accept its terms. //
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define LAST_VERSION "2.5 2022-12-08 eMailShrinker"
|
#include "version.hpp"
|
||||||
|
const std::string kaz::LAST_VERSION_NUM ("2.6");
|
||||||
|
const std::string kaz::LAST_VERSION_DATE ("2022-12-09");
|
||||||
|
const std::string kaz::LAST_VERSION (LAST_VERSION+" "+LAST_VERSION_DATE+" eMailShrinker");
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -232,4 +235,4 @@ main (int argc, char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
|
@ -439,9 +439,14 @@ void
|
|||||||
kaz::removeQuote (string &content) {
|
kaz::removeQuote (string &content) {
|
||||||
if (content.empty () || content [0] != '"')
|
if (content.empty () || content [0] != '"')
|
||||||
return;
|
return;
|
||||||
|
string::size_type stop = (1);
|
||||||
string::size_type stop = content.find ('"', 1);
|
for (;;) {
|
||||||
content = stop ?
|
stop = content.find ('"', stop);
|
||||||
|
if (stop == string::npos || content [stop-1] != '\\')
|
||||||
|
break;
|
||||||
|
++stop;
|
||||||
|
}
|
||||||
|
content = (stop != string::npos) ?
|
||||||
content.substr (1, stop-1) :
|
content.substr (1, stop-1) :
|
||||||
content.substr (1);
|
content.substr (1);
|
||||||
}
|
}
|
||||||
|
48
src/include/version.hpp
Normal file
48
src/include/version.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright KAZ 2021 //
|
||||||
|
// //
|
||||||
|
// contact (at) kaz.bzh //
|
||||||
|
// //
|
||||||
|
// This software is a filter to shrink email by attachment extraction. //
|
||||||
|
// //
|
||||||
|
// This software is governed by the CeCILL-B license under French law and //
|
||||||
|
// abiding by the rules of distribution of free software. You can use, //
|
||||||
|
// modify and/or redistribute the software under the terms of the //
|
||||||
|
// CeCILL-B license as circulated by CEA, CNRS and INRIA at the following //
|
||||||
|
// URL "http://www.cecill.info". //
|
||||||
|
// //
|
||||||
|
// As a counterpart to the access to the source code and rights to copy, //
|
||||||
|
// modify and redistribute granted by the license, users are provided //
|
||||||
|
// only with a limited warranty and the software's author, the holder of //
|
||||||
|
// the economic rights, and the successive licensors have only limited //
|
||||||
|
// liability. //
|
||||||
|
// //
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated //
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the //
|
||||||
|
// software by the user in light of its specific status of free software, //
|
||||||
|
// that may mean that it is complicated to manipulate, and that also //
|
||||||
|
// therefore means that it is reserved for developers and experienced //
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore //
|
||||||
|
// encouraged to load and test the software's suitability as regards //
|
||||||
|
// their requirements in conditions enabling the security of their //
|
||||||
|
// systems and/or data to be ensured and, more generally, to use and //
|
||||||
|
// operate it in the same conditions as regards security. //
|
||||||
|
// //
|
||||||
|
// The fact that you are presently reading this means that you have had //
|
||||||
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _kaz_version_hpp
|
||||||
|
#define _kaz_version_hpp
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace kaz {
|
||||||
|
// ================================================================================
|
||||||
|
|
||||||
|
extern const std::string LAST_VERSION_NUM, LAST_VERSION_DATE, LAST_VERSION;
|
||||||
|
|
||||||
|
// ================================================================================
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _kaz_version_hpp
|
Loading…
Reference in New Issue
Block a user