Compare commits
4 Commits
99e888f5d1
...
develop
Author | SHA1 | Date | |
---|---|---|---|
29480b299c | |||
6def55c5a7 | |||
c448478c39 | |||
b4ea2185f0 |
11
README.md
11
README.md
@ -41,3 +41,14 @@ git clone https://git.kaz.bzh/KAZ/depollueur.git
|
|||||||
|
|
||||||
make -j $(nproc)
|
make -j $(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##Astuces
|
||||||
|
|
||||||
|
|
||||||
|
Pour la mise au point dans Kaz, il faut bloquer la mise à jour automatique avec :
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
touch /kaz/git/depollueur/dontupdage
|
||||||
|
/kaz/bin/container.sh stop jirafeau postfix; docker system prune; /kaz/bin/install.sh jirafeau postfix
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
a.php?s=mel@domain.org&t=password + [action] => manage account
|
a.php?s=mel@domain.org&t=password + [action] => manage account
|
||||||
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter]
|
action: a=login a=logout a=r[on|off] a=p[minute|hour|day|week|month|quarter]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use PHPMailer\PHPMailer\SMTP;
|
use PHPMailer\PHPMailer\SMTP;
|
||||||
use PHPMailer\PHPMailer\Exception;
|
use PHPMailer\PHPMailer\Exception;
|
||||||
@ -45,7 +46,7 @@ define ('E_BAD_ARCHIVE_NAME', 'Bad archive name format');
|
|||||||
define ('E_CREATE_ZIP', "Impossible de créer l'archive.");
|
define ('E_CREATE_ZIP', "Impossible de créer l'archive.");
|
||||||
define ('E_OPEN_ZIP', "Impossible d'ouvrir l'archive.");
|
define ('E_OPEN_ZIP', "Impossible d'ouvrir l'archive.");
|
||||||
define ('M_BAD_KEY', "Mauvaise clef pour ");
|
define ('M_BAD_KEY', "Mauvaise clef pour ");
|
||||||
define ('M_BAD_SENDER_NAME', 'Votre mèl est incorrect');
|
define ('M_BAD_SENDER_NAME', 'Votre mél est incorrect');
|
||||||
define ('M_BAD_TOKEN', "Vous n'utilisez pas le bon jeton (consultez votre messagerie).");
|
define ('M_BAD_TOKEN', "Vous n'utilisez pas le bon jeton (consultez votre messagerie).");
|
||||||
define ('M_TOO_LONG_BEFORE_LOGGED', "Jeton de connexion trop ancien.");
|
define ('M_TOO_LONG_BEFORE_LOGGED', "Jeton de connexion trop ancien.");
|
||||||
define ('M_TOO_LONG_LOGGED', "Temps de connexion dépassé.");
|
define ('M_TOO_LONG_LOGGED', "Temps de connexion dépassé.");
|
||||||
@ -60,7 +61,7 @@ define ('M_FILES_RENAMED', " fichiers renommés.");
|
|||||||
define ('M_FILE_NOT_FOUND', " fichier est expiré.");
|
define ('M_FILE_NOT_FOUND', " fichier est expiré.");
|
||||||
define ('M_FILE_RENAMED', " fichier renommé.");
|
define ('M_FILE_RENAMED', " fichier renommé.");
|
||||||
define ('M_INTRO_FORM', "Quelles sont les informations me concernant ?");
|
define ('M_INTRO_FORM', "Quelles sont les informations me concernant ?");
|
||||||
define ('M_MEL', "votre mèl");
|
define ('M_MEL', "votre mél");
|
||||||
define ('M_NO_FILENAME', 'SansNom');
|
define ('M_NO_FILENAME', 'SansNom');
|
||||||
define ('M_NO_SENDER', 'kaz-');
|
define ('M_NO_SENDER', 'kaz-');
|
||||||
define ('M_NEW_ATTACHEMENT_DIRNAME', "nouveau");
|
define ('M_NEW_ATTACHEMENT_DIRNAME', "nouveau");
|
||||||
@ -155,6 +156,19 @@ if (isset ($_REQUEST [A_PERIOD]) && !empty ($_REQUEST [A_PERIOD])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========================================
|
||||||
|
if (isset ($_REQUEST [A_LANG]) && !empty ($_REQUEST [A_LANG])) {
|
||||||
|
if (!preg_match ("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i", $_REQUEST [A_LANG]))
|
||||||
|
$content = DEFAULT_LANG.NL;
|
||||||
|
else
|
||||||
|
$content = getSenderLang ($_REQUEST [A_LANG]).NL;
|
||||||
|
header ('HTTP/1.0 200 OK');
|
||||||
|
header ('Content-Length: ' . strlen ($content));
|
||||||
|
header ('Content-Type: text/plain');
|
||||||
|
echo $content;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
$doUpdate = false;
|
$doUpdate = false;
|
||||||
if (isset ($_REQUEST [A_UPDATE]) && !empty ($_REQUEST [A_UPDATE])) {
|
if (isset ($_REQUEST [A_UPDATE]) && !empty ($_REQUEST [A_UPDATE])) {
|
||||||
@ -748,10 +762,17 @@ if ($doDownload) {
|
|||||||
$modif = true;
|
$modif = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$srcName = $dstName = ($link ['file_name'] ? $link ['file_name'] : M_NO_FILENAME);
|
$dstName = ($link ['file_name'] ? $link ['file_name'] : M_NO_FILENAME);
|
||||||
if (in_array ($srcName, $singleName))
|
if (in_array ($dstName, $singleName)) {
|
||||||
for ($i = 0; $i < 10000; ++$i) {
|
$dstFilename = $dstName;
|
||||||
$dstName = sprintf ("%s-%2d", $srcName, $i);
|
$dstExtension = "";
|
||||||
|
$dstExtensionPos = strrpos ($dstName, '.');
|
||||||
|
if ($dstExtensionPos) {
|
||||||
|
$dstFilename = substr ($dstName, 0, $dstExtensionPos);
|
||||||
|
$dstExtension = substr ($dstName, $dstExtensionPos);
|
||||||
|
}
|
||||||
|
for ($i = 1; $i < 10000; ++$i) {
|
||||||
|
$dstName = sprintf ("%s-%02d%s", $dstFilename, $i, $dstExtension);
|
||||||
if (!in_array ($dstName, $singleName)) {
|
if (!in_array ($dstName, $singleName)) {
|
||||||
if (isset ($archiveContent [T_RENAME]))
|
if (isset ($archiveContent [T_RENAME]))
|
||||||
++$archiveContent [T_RENAME];
|
++$archiveContent [T_RENAME];
|
||||||
@ -761,6 +782,7 @@ if ($doDownload) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$singleName [] = $dstName;
|
$singleName [] = $dstName;
|
||||||
$archiveContent [$cat][T_ENTRIES][] = [T_HASH => $link ['hash'], T_FILENAME => $dstName, T_CRYPT_KEY => $cryptKey, T_CRYPTED => $link ['crypted']];
|
$archiveContent [$cat][T_ENTRIES][] = [T_HASH => $link ['hash'], T_FILENAME => $dstName, T_CRYPT_KEY => $cryptKey, T_CRYPTED => $link ['crypted']];
|
||||||
}
|
}
|
||||||
@ -871,7 +893,7 @@ if (isset ($_REQUEST [A_ACTION]) && $_REQUEST [A_ACTION] == T_LOGIN && $sender)
|
|||||||
echo M_SEND_TOKEN;
|
echo M_SEND_TOKEN;
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
"Erreur dans l'envoi. Véritiez votre mèl.";
|
"Erreur dans l'envoi. Véritiez votre mél.";
|
||||||
}
|
}
|
||||||
echo "<br/><br/><br/>";
|
echo "<br/><br/><br/>";
|
||||||
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
require (JIRAFEAU_ROOT.'lib/template/footer.php');
|
||||||
@ -1065,6 +1087,7 @@ div.frame {border: 1px; border-style: solid; padding: 1em; margin: 1em;}
|
|||||||
$defaultChecked = [];
|
$defaultChecked = [];
|
||||||
$defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
|
$defaultChecked [isSenderTrack ($sender) ? "on" : "off"] = ' checked="checked"';
|
||||||
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
|
$defaultChecked [getSenderPeriod ($sender)] = ' selected="selected"';
|
||||||
|
$defaultChecked [getSenderLang ($sender)] = ' selected="selected"';
|
||||||
echo
|
echo
|
||||||
'<form method="post">'.
|
'<form method="post">'.
|
||||||
'Je veux que Kaz suive tous mes futurs envois: '.
|
'Je veux que Kaz suive tous mes futurs envois: '.
|
||||||
@ -1080,6 +1103,15 @@ echo
|
|||||||
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
foreach ($periodText as $item => $text)
|
foreach ($periodText as $item => $text)
|
||||||
echo ' <option value="'.A_PERIOD.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
echo ' <option value="'.A_PERIOD.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
||||||
|
echo
|
||||||
|
'</select> '.
|
||||||
|
'<button type="submit">'."valider".'</button>'.
|
||||||
|
'</form>'.
|
||||||
|
'<form method="post">'.
|
||||||
|
'Je préfère envoyer mes messages en langue '.
|
||||||
|
'<select name="'.A_ACTION.'" style="width: auto !important;">';
|
||||||
|
foreach ($langText as $item => $text)
|
||||||
|
echo ' <option value="'.A_LANG.$item.'"'.$defaultChecked [$item].'>'.$text.'</option>';
|
||||||
echo
|
echo
|
||||||
'</select> '.
|
'</select> '.
|
||||||
'<button type="submit">'."valider".'</button>'.
|
'<button type="submit">'."valider".'</button>'.
|
||||||
|
@ -66,6 +66,7 @@ ARCHIVE_TITLE="archive_content"
|
|||||||
ARCHIVE_MIME="text/kaz_email_archive"
|
ARCHIVE_MIME="text/kaz_email_archive"
|
||||||
|
|
||||||
KEEP_FAILED=true
|
KEEP_FAILED=true
|
||||||
|
DEBUG=
|
||||||
|
|
||||||
#################### FONCTIONS ############################################
|
#################### FONCTIONS ############################################
|
||||||
BOLD='[1m'
|
BOLD='[1m'
|
||||||
@ -134,7 +135,7 @@ ARCHIVE_CONTENT="${REP_PIECE_JOINTE}/archive-content.txt"
|
|||||||
JIRAFEAU_ERROR="${REP_PIECE_JOINTE}/jirafeau-error.txt"
|
JIRAFEAU_ERROR="${REP_PIECE_JOINTE}/jirafeau-error.txt"
|
||||||
|
|
||||||
# Clean up when done or when aborting.
|
# Clean up when done or when aborting.
|
||||||
trap "rm -rf in.$$ in.$$.altered ${REP_PIECE_JOINTE}" 0 1 2 3 15
|
[ -z "${DEBUG}" ] && trap "rm -rf in.$$ in.$$.altered ${REP_PIECE_JOINTE}" 0 1 2 3 15
|
||||||
|
|
||||||
if ! cat > "in.$$"; then
|
if ! cat > "in.$$"; then
|
||||||
LOG_FIC "${RED}Cannot save mail to file${NC}"
|
LOG_FIC "${RED}Cannot save mail to file${NC}"
|
||||||
@ -142,8 +143,7 @@ if ! cat > "in.$$"; then
|
|||||||
fi
|
fi
|
||||||
LOG_FIC "\n" \
|
LOG_FIC "\n" \
|
||||||
" size: ${YELLOW}$(wc -c < "${INSPECT_DIR}/in.$$")${NC}"
|
" size: ${YELLOW}$(wc -c < "${INSPECT_DIR}/in.$$")${NC}"
|
||||||
# XXX trace
|
[ -n "${DEBUG}" ] && (mkdir -p "${DIR_LOG}/pb/" ; cp "${INSPECT_DIR}/in.$$" "${DIR_LOG}/pb/in.$$.orig")
|
||||||
# cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.bak"
|
|
||||||
|
|
||||||
mkdir -p "${REP_PIECE_JOINTE}/"
|
mkdir -p "${REP_PIECE_JOINTE}/"
|
||||||
>"${OLD_LINKS}"
|
>"${OLD_LINKS}"
|
||||||
@ -156,8 +156,7 @@ echo "time: ${DATE_TEMPS}\nid: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
|||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\"${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -u \"${INSPECT_DIR}/in.$$\" 2>> \"${FIC_LOG}\" > \"${OLD_LINKS}\"${NC}"
|
||||||
"${SHRINK_CMD}" -u "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" > "${OLD_LINKS}"
|
"${SHRINK_CMD}" -u "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" > "${OLD_LINKS}"
|
||||||
|
|
||||||
cat "${OLD_LINKS}" | grep "${JIRAFEAU_URL}" | while read REMOTE_LINK
|
cat "${OLD_LINKS}" | grep "${JIRAFEAU_URL}" | while read REMOTE_LINK; do
|
||||||
do
|
|
||||||
REMOTE_REF=$(echo "${REMOTE_LINK}" | sed -e 's/.*h=\([^&]*\).*/\1/' -e 's/.*http.*//')
|
REMOTE_REF=$(echo "${REMOTE_LINK}" | sed -e 's/.*h=\([^&]*\).*/\1/' -e 's/.*http.*//')
|
||||||
[ -z "${REMOTE_REF}" ] && continue
|
[ -z "${REMOTE_REF}" ] && continue
|
||||||
REMOTE_KEY=$(echo "${REMOTE_LINK}" | grep "k=" | sed 's%.*k=\([^&]*\).*%\1%')
|
REMOTE_KEY=$(echo "${REMOTE_LINK}" | grep "k=" | sed 's%.*k=\([^&]*\).*%\1%')
|
||||||
@ -171,10 +170,8 @@ LOG_FIC " - archive starts with: ${NL}${YELLOW}$(cat ${ARCHIVE_CONTENT})${NC}"
|
|||||||
# Etape extraction des pieces jointes
|
# Etape extraction des pieces jointes
|
||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${INSPECT_DIR}/in.$$ ${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${INSPECT_DIR}/in.$$ ${NC}"
|
||||||
"${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" -d "${REP_PIECE_JOINTE}" "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" | {
|
"${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" -d "${REP_PIECE_JOINTE}" "${INSPECT_DIR}/in.$$" 2>> "${FIC_LOG}" | {
|
||||||
while read ATTACH_TMP_NAME
|
while read ATTACH_TMP_NAME; do
|
||||||
do
|
if [ -d "${ATTACH_TMP_NAME}" ]; then
|
||||||
if [ -d "${ATTACH_TMP_NAME}" ]
|
|
||||||
then
|
|
||||||
ATTACH_MEDIA="${ATTACH_TMP_NAME}/media"
|
ATTACH_MEDIA="${ATTACH_TMP_NAME}/media"
|
||||||
ATTACH_NAME=$(grep "^Name: " "${ATTACH_TMP_NAME}/meta" | cut -c 7- )
|
ATTACH_NAME=$(grep "^Name: " "${ATTACH_TMP_NAME}/meta" | cut -c 7- )
|
||||||
ATTACH_CONTENT_TYPE=$(grep "^Content-Type: " "${ATTACH_TMP_NAME}/meta" | cut -c 15- )
|
ATTACH_CONTENT_TYPE=$(grep "^Content-Type: " "${ATTACH_TMP_NAME}/meta" | cut -c 15- )
|
||||||
@ -195,7 +192,7 @@ LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${IN
|
|||||||
case "${JIR_TOKEN}" in
|
case "${JIR_TOKEN}" in
|
||||||
"" | no | *Error* | \<* )
|
"" | no | *Error* | \<* )
|
||||||
LOG_FIC " - ${RED}Can't upload <${ATTACH_NAME}> <${ATTACH_CONTENT_TYPE}> <$(wc -c < "${ATTACH_MEDIA}")> (${JIR_TOKEN}) <in.$$.bak>. It will be not change in e-mail.${NC}"
|
LOG_FIC " - ${RED}Can't upload <${ATTACH_NAME}> <${ATTACH_CONTENT_TYPE}> <$(wc -c < "${ATTACH_MEDIA}")> (${JIR_TOKEN}) <in.$$.bak>. It will be not change in e-mail.${NC}"
|
||||||
echo "new:"
|
echo "url:"
|
||||||
keepFailed "${INSPECT_DIR}/in.$$"
|
keepFailed "${INSPECT_DIR}/in.$$"
|
||||||
echo "UPLOAD_FAIL" >> "${JIRAFEAU_ERROR}"
|
echo "UPLOAD_FAIL" >> "${JIRAFEAU_ERROR}"
|
||||||
;;
|
;;
|
||||||
@ -243,8 +240,7 @@ LOG_FIC "${CYAN}${SHRINK_CMD} -s ${MAX_KEEP_IN_MAIL} -d ${REP_PIECE_JOINTE} ${IN
|
|||||||
LOG_FIC "${CYAN}${SHRINK_CMD} -s \"${MAX_KEEP_IN_MAIL}\" \"${INSPECT_DIR}/in.$$\" \"${INSPECT_DIR}/in.$$.altered\" 2>> \"${FIC_LOG}\"${NC}"
|
LOG_FIC "${CYAN}${SHRINK_CMD} -s \"${MAX_KEEP_IN_MAIL}\" \"${INSPECT_DIR}/in.$$\" \"${INSPECT_DIR}/in.$$.altered\" 2>> \"${FIC_LOG}\"${NC}"
|
||||||
} | "${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" 2>> "${FIC_LOG}"
|
} | "${SHRINK_CMD}" -s "${MAX_KEEP_IN_MAIL}" "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" 2>> "${FIC_LOG}"
|
||||||
|
|
||||||
# XXX trace
|
[ -n "${DEBUG}" ] && (mkdir -p "${DIR_LOG}/pb/" ; cp "${INSPECT_DIR}/in.$$.altered" "${DIR_LOG}/pb/in.$$.altered")
|
||||||
# cp "${INSPECT_DIR}/in.$$" "${INSPECT_DIR}/in.$$.altered" /var/mail/tmp/
|
|
||||||
|
|
||||||
if [ -s "${JIRAFEAU_ERROR}" ]; then
|
if [ -s "${JIRAFEAU_ERROR}" ]; then
|
||||||
LOG_FIC " - ${RED}upload fail${NC}"
|
LOG_FIC " - ${RED}upload fail${NC}"
|
||||||
|
@ -65,7 +65,14 @@ const string Attachment::ALTERNATIVE ("alternative");
|
|||||||
|
|
||||||
const regex Attachment::nameCharsetRegEx (".*name\\*=(.*)");
|
const regex Attachment::nameCharsetRegEx (".*name\\*=(.*)");
|
||||||
const regex Attachment::nameRegEx (".*name=\"([^\"]*)\".*");
|
const regex Attachment::nameRegEx (".*name=\"([^\"]*)\".*");
|
||||||
const regex Attachment::boundaryRegEx (".*boundary=\"?([^\" ]*)\"?.*");
|
// boundary="----=_Part_796779_1154936629.1668080348646"
|
||||||
|
// boundary="------------040709000505010508040808"
|
||||||
|
// boundary="----------=_1668606031-941125-91"
|
||||||
|
// boundary="_004_PAVPR10MB6792713B313048E3A259B215B2079PAVPR10MB6792EURP_";
|
||||||
|
// boundary="_000_PAVPR10MB6792713B313048E3A259B215B2079PAVPR10MB6792EURP_"
|
||||||
|
// boundary=--boundary_1351_64006126-2b0e-4a3b-98ac-4797d1634188
|
||||||
|
// boundary=--boundary_1352_7e294c9a-cfab-44a0-bfb3-7310380ac7cb;
|
||||||
|
const regex Attachment::boundaryRegEx (".*boundary=\"?([^\"; ]*)\"?;?.*");
|
||||||
const regex Attachment::cidDefRegEx (".*<([^>]*)>.*");
|
const regex Attachment::cidDefRegEx (".*<([^>]*)>.*");
|
||||||
const regex Attachment::textRegEx (".*text/("+PLAIN+"|"+HTML+").*");
|
const regex Attachment::textRegEx (".*text/("+PLAIN+"|"+HTML+").*");
|
||||||
const regex Attachment::multiRegEx ("\\s*multipart/(mixed|"+RELATED+"|"+ALTERNATIVE+").*");
|
const regex Attachment::multiRegEx ("\\s*multipart/(mixed|"+RELATED+"|"+ALTERNATIVE+").*");
|
||||||
@ -354,7 +361,11 @@ Attachment::nextBondary (ifstream &mbox, streamoff &curPos) {
|
|||||||
++it)
|
++it)
|
||||||
if (couple.find (*it) != string::npos) {
|
if (couple.find (*it) != string::npos) {
|
||||||
LOG ("find: "+ *it);
|
LOG ("find: "+ *it);
|
||||||
subAttachements.back ().toUpdate = true;
|
LOG ("size: " << subAttachements.size ());
|
||||||
|
if (subAttachements.size ())
|
||||||
|
subAttachements.back ().toUpdate = true;
|
||||||
|
else
|
||||||
|
LOG_BUG (true, continue, "eMailShrinker: bug A10: boundary format ? " << *this);
|
||||||
}
|
}
|
||||||
prev = clearLine;
|
prev = clearLine;
|
||||||
continue;
|
continue;
|
||||||
@ -489,7 +500,7 @@ kaz::operator << (ostream& os, const Attachment& attachment) {
|
|||||||
if (prop.length ())
|
if (prop.length ())
|
||||||
prop = " ["+prop+"]";
|
prop = " ["+prop+"]";
|
||||||
|
|
||||||
os << setw ((attachment.level % 20)*2) << "" << setw (10) << SizeArg (attachment.getSize ()) << " " << attachment.getContentType ()
|
os << ("****************************************"+40-(attachment.level % 20)*2) << setw (10) << SizeArg (attachment.getSize ()) << " " << attachment.getContentType ()
|
||||||
<< prop << (attachment.cid.length () ? " id: "+attachment.cid : "")
|
<< prop << (attachment.cid.length () ? " id: "+attachment.cid : "")
|
||||||
<< (attachment.boundary.length () ? " boundary: "+attachment.boundary : "")
|
<< (attachment.boundary.length () ? " boundary: "+attachment.boundary : "")
|
||||||
<< " (" << attachment.beginPos << " / " << attachment.contentPos << " / " << attachment.endPos << ") " << endl;
|
<< " (" << attachment.beginPos << " / " << attachment.contentPos << " / " << attachment.endPos << ") " << endl;
|
||||||
|
@ -32,14 +32,15 @@
|
|||||||
// knowledge of the CeCILL-B license and that you accept its terms. //
|
// knowledge of the CeCILL-B license and that you accept its terms. //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <iostream>
|
#include <algorithm>
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <algorithm>
|
#include <regex>
|
||||||
|
#include <set>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "kazDebug.hpp"
|
#include "kazDebug.hpp"
|
||||||
#include "kazMisc.hpp"
|
#include "kazMisc.hpp"
|
||||||
@ -50,64 +51,75 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace kaz;
|
using namespace kaz;
|
||||||
|
|
||||||
static const string KAZ_WEB_SITE = "https://kaz.bzh/";
|
static const string KAZ_WEB_SITE ("https://kaz.bzh/");
|
||||||
static const string TMPL_DOWNLOAD = "{{DOWNLOAD}}";
|
static const string TMPL_DOWNLOAD ("{{DOWNLOAD}}");
|
||||||
static const string TMPL_FILENAME = "{{FILENAME}}";
|
static const string TMPL_FILENAME ("{{FILENAME}}");
|
||||||
static const string CID = "cid:";
|
static const string CID ("cid:");
|
||||||
|
|
||||||
static const string KAZ_PLAIN_HR = "______________________________________________________________________________";
|
// "l=/" => v1 compatibility
|
||||||
static const string KAZ_PLAIN_START = "~~ PJ-KAZ !"; // don't end whith space
|
static const regex archiveURLSignature (".*(([&?]g=)|([&?]l=/)).*");
|
||||||
static const string KAZ_PLAIN_STOP = KAZ_PLAIN_START+" ~~";
|
|
||||||
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_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. Pour mieux comprendre la politique de nos services visitez kaz.bzh";
|
|
||||||
static const string KAZ_PLAIN_DOWLOAD_ONE = "Vos pièces jointes sont à télécharger individuellement ici :";
|
|
||||||
static const string KAZ_PLAIN_DOWLOAD_OTHER = "(Contenu dans des messages précédents)";
|
|
||||||
static const string KAZ_PLAIN_DOWLOAD_ALL = "Vous pouvez télécharger l'ensemble dans une archive là :";
|
|
||||||
|
|
||||||
static const string HEAD = "<head>";
|
|
||||||
static const string HEAD_END = "</head>";
|
|
||||||
static const string KAZ_CSS_URL = "https://kaz.bzh/m/email.css";
|
|
||||||
static const string KAZ_CSS = "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" href=\""+KAZ_CSS_URL+"\"/>";
|
|
||||||
static const string A_END = "</a>";
|
|
||||||
static const string LI_BEGIN = "<li";
|
|
||||||
static const string CLASS_ONE = "class=\"one\"";
|
|
||||||
static const string LI_ONE = LI_BEGIN+" "+CLASS_ONE+">";
|
|
||||||
static const string LI_ALL = LI_BEGIN+" class=\"all\">";
|
|
||||||
static const string LI_END = "</li>";
|
|
||||||
static const string HREF_ONE = "href=\"";
|
|
||||||
static const string BODY_END = "</body>";
|
|
||||||
static const string HTML_END = "</html>";
|
|
||||||
|
|
||||||
static const string KAZ_HTML_TAG = "<!--KAZ"; // don't end whith space
|
static const string KAZ_PLAIN_HR ("______________________________________________________________________________");
|
||||||
static const string KAZ_HTML_START = KAZ_HTML_TAG+" START-->";
|
static const string KAZ_PLAIN_START ("~~ PJ-KAZ !"); // don't end whith space
|
||||||
static const string KAZ_HTML_STOP = KAZ_HTML_TAG+" STOP-->";
|
static const string KAZ_PLAIN_STOP (KAZ_PLAIN_START+" ~~");
|
||||||
|
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_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. "
|
||||||
|
"Pour mieux comprendre la politique de nos services visitez kaz.bzh");
|
||||||
|
static const string KAZ_PLAIN_DOWLOAD_ONE ("Vos pièces jointes sont à télécharger individuellement ici :");
|
||||||
|
static const string KAZ_PLAIN_DOWLOAD_OTHER ("(Contenu dans des messages précédents)");
|
||||||
|
static const string KAZ_PLAIN_DOWLOAD_ALL ("Vous pouvez télécharger l'ensemble dans une archive là :");
|
||||||
|
|
||||||
|
static const string HEAD ("<head>");
|
||||||
|
static const string HEAD_END ("</head>");
|
||||||
|
static const string KAZ_CSS_URL ("https://kaz.bzh/m/email.css");
|
||||||
|
static const string KAZ_CSS ("<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" href=\""+KAZ_CSS_URL+"\"/>");
|
||||||
|
static const string A_END ("</a>");
|
||||||
|
static const string LI_BEGIN ("<li");
|
||||||
|
static const string CLASS_ONE ("class=\"one\"");
|
||||||
|
static const string LI_ONE (LI_BEGIN+" "+CLASS_ONE+">");
|
||||||
|
static const string LI_ALL (LI_BEGIN+" class=\"all\">");
|
||||||
|
static const string LI_END ("</li>");
|
||||||
|
static const string HREF_ONE ("href=\"");
|
||||||
|
static const string BODY_END ("</body>");
|
||||||
|
static const string HTML_END ("</html>");
|
||||||
|
|
||||||
|
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
|
// 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)");
|
||||||
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à :");
|
||||||
static const string KAZ_HTML_ARCHIVE = "archive";
|
static const string KAZ_HTML_ARCHIVE ("archive");
|
||||||
|
|
||||||
|
static const string KAZ_EMPTY_TEXT_PLAIN ("Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: base64\n");
|
||||||
|
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
vector <string>
|
vector <string>
|
||||||
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
Attachment::stringsToUpdate ({KAZ_PLAIN_START, "\""+CID});
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
const string MainAttachment::templatePlainAddLink (" - "+TMPL_DOWNLOAD+" "+TMPL_FILENAME+"\r\n");
|
const string MainAttachment::templatePlainAddLink (" * "+TMPL_FILENAME+" <"+TMPL_DOWNLOAD+">\r\n");
|
||||||
const string MainAttachment::templatePlainAllLink ("\r\n"+KAZ_PLAIN_DOWLOAD_ALL+"\r\n * "+TMPL_DOWNLOAD+"\r\n");
|
const string MainAttachment::templatePlainAllLink ("\r\n * "+KAZ_PLAIN_DOWLOAD_ALL+" <"+TMPL_DOWNLOAD+">\r\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\">"
|
||||||
"<p style=\"font-size:10px; color:#969696;\">"+KAZ_HTML_DONT_TOUCH+"</p>\n"
|
"<p style=\"font-size:10px; color:#969696;\">"+KAZ_HTML_DONT_TOUCH+"</p>\n"
|
||||||
"<p>"+KAZ_HTML_DOWLOAD_ONE+"<ul>\n");
|
"<p>"+KAZ_HTML_DOWLOAD_ONE+"<ul>\n");
|
||||||
const string MainAttachment::templateHtmlAddLink (LI_ONE+"<a "+HREF_ONE+TMPL_DOWNLOAD+"\">"+TMPL_FILENAME+"</a>"+LI_END+"\n");
|
const string MainAttachment::templateHtmlAddLink (LI_ONE+"<a "+HREF_ONE+TMPL_DOWNLOAD+"\">"+TMPL_FILENAME+"</a>"+LI_END+"\n");
|
||||||
const string MainAttachment::templateHtmlOtherLink ("</ul>"+KAZ_HTML_DOWLOAD_OTHER+"<ul>\n");
|
const string MainAttachment::templateHtmlOtherLink ("</ul>"+KAZ_HTML_DOWLOAD_OTHER+"<ul>\n");
|
||||||
const string MainAttachment::templateHtmlAllLink ("</ul><ul>"+LI_ALL+KAZ_HTML_DOWLOAD_ALL+" <a href=\""+TMPL_DOWNLOAD+"\">"+KAZ_HTML_ARCHIVE+"</a>"+LI_END+"\n");
|
const string MainAttachment::templateHtmlAllLink ("</ul><ul>"+LI_ALL+KAZ_HTML_DOWLOAD_ALL+" <a href=\""+TMPL_DOWNLOAD+"\">"+KAZ_HTML_ARCHIVE+"</a>"+LI_END+"\n");
|
||||||
const string MainAttachment::templateHtmlFooter ("</ul></p>\n"
|
const string MainAttachment::templateHtmlFooter ("</ul></p>\n"
|
||||||
"<p class=\"msg\"><a class=\"kaz\" href=\""+KAZ_WEB_SITE+"\"> "+KAZ_WEB_SITE+" </a></p></div>\n"
|
"<p class=\"msg\"><a class=\"kaz\" href=\""+KAZ_WEB_SITE+"\"> "+KAZ_WEB_SITE+" </a></p></div>\n"
|
||||||
"<hr><p style=\"font-size:10px; color:#969696;\">"+KAZ_PLAIN_STOP+"</p>"+KAZ_HTML_STOP+"\n");
|
"<hr><p style=\"font-size:10px; color:#969696;\">"+KAZ_PLAIN_STOP+"</p>"+KAZ_HTML_STOP+"\n");
|
||||||
|
|
||||||
const regex MainAttachment::whiteSpaceRegEx ("\\s+");
|
const regex MainAttachment::whiteSpaceRegEx ("\\s+");
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
void
|
void
|
||||||
@ -167,7 +179,8 @@ MainAttachment::addLink (string &plain, string &html, const string &url, const s
|
|||||||
plain += plainNewOneLink;
|
plain += plainNewOneLink;
|
||||||
string htmlNewOneLink (templateHtmlAddLink);
|
string htmlNewOneLink (templateHtmlAddLink);
|
||||||
string codedUrl (url);
|
string codedUrl (url);
|
||||||
replaceAll (codedUrl, "&", "&");
|
// XXX amp ?
|
||||||
|
//replaceAll (codedUrl, "&", "&");
|
||||||
replaceAll (htmlNewOneLink, TMPL_DOWNLOAD, codedUrl);
|
replaceAll (htmlNewOneLink, TMPL_DOWNLOAD, codedUrl);
|
||||||
replaceAll (htmlNewOneLink, TMPL_FILENAME, name);
|
replaceAll (htmlNewOneLink, TMPL_FILENAME, name);
|
||||||
html += htmlNewOneLink;
|
html += htmlNewOneLink;
|
||||||
@ -218,11 +231,11 @@ MainAttachment::getDisclaim (string &plain, string &html) const {
|
|||||||
string allPlainLinks (templatePlainAllLink);
|
string allPlainLinks (templatePlainAllLink);
|
||||||
replaceAll (allPlainLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
replaceAll (allPlainLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
||||||
plain += allPlainLinks;
|
plain += allPlainLinks;
|
||||||
string allLinks (templateHtmlAllLink);
|
string allHtmlLinks (templateHtmlAllLink);
|
||||||
replaceAll (allLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
replaceAll (allHtmlLinks, TMPL_DOWNLOAD, archiveDownloadURL);
|
||||||
html += allLinks;
|
html += allHtmlLinks;
|
||||||
}
|
}
|
||||||
html += templateHtmlFooter;
|
html += templateHtmlFooter+"\r\n";
|
||||||
plain += "\r\n\r\n"+KAZ_WEB_SITE+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_STOP+"\r\n";
|
plain += "\r\n\r\n"+KAZ_WEB_SITE+"\r\n"+KAZ_PLAIN_HR+"\r\n"+KAZ_PLAIN_STOP+"\r\n";
|
||||||
// & => & done
|
// & => & done
|
||||||
LOG ("plain: " << plain);
|
LOG ("plain: " << plain);
|
||||||
@ -245,6 +258,7 @@ MainAttachment::addPrevious (const string &href, const string &name, const bool
|
|||||||
|
|
||||||
void
|
void
|
||||||
MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
||||||
|
// plain text => "* name <url>"
|
||||||
DEF_LOG ("Attachment::extractedPlainKAZ", "extractedPlainKAZ: " << extractedPlainKAZ);
|
DEF_LOG ("Attachment::extractedPlainKAZ", "extractedPlainKAZ: " << extractedPlainKAZ);
|
||||||
for (string::size_type startPos (0);
|
for (string::size_type startPos (0);
|
||||||
(startPos = extractedPlainKAZ.find ("http", startPos)) != string::npos;
|
(startPos = extractedPlainKAZ.find ("http", startPos)) != string::npos;
|
||||||
@ -257,22 +271,30 @@ MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
|||||||
|
|
||||||
if (extractedPlainKAZ [stopPos])
|
if (extractedPlainKAZ [stopPos])
|
||||||
++stopPos;
|
++stopPos;
|
||||||
|
streamoff stopName = startPos;
|
||||||
startPos = stopPos;
|
startPos = stopPos;
|
||||||
|
|
||||||
// get all href but KAZ_WEB_SITE
|
// get all href but KAZ_WEB_SITE
|
||||||
// the archive link will be skip by filter.sh
|
// the archive link will be skip by filter.sh
|
||||||
if (href == KAZ_WEB_SITE)
|
if (href == KAZ_WEB_SITE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string::size_type nextPos = extractedPlainKAZ.find ("http", startPos);
|
// backward find name
|
||||||
string name (extractedPlainKAZ, startPos, (nextPos == string::npos ? extractedPlainKAZ.length () : nextPos) - startPos);
|
string::size_type startName = extractedPlainKAZ.rfind ("* ", stopName);
|
||||||
// skip [> \r\n\t]
|
string name;
|
||||||
nextPos = name.find_first_not_of ("[> \t\r\n\"]");
|
|
||||||
if (nextPos != string::npos)
|
if (startName != string::npos) {
|
||||||
name.erase (0, nextPos);
|
name = string (extractedPlainKAZ, startName+3, stopName - startName - 3);
|
||||||
// stop before [>\r\n\t]
|
// skip [> \r\n\t]
|
||||||
nextPos = name.find_first_of ("[\"]");
|
string::size_type nextPos = name.find_first_not_of ("[>< \t\r\n\"]");
|
||||||
if (nextPos != string::npos)
|
if (nextPos != string::npos)
|
||||||
name.erase (nextPos);
|
name.erase (0, nextPos);
|
||||||
|
// stop before [>\r\n\t]
|
||||||
|
nextPos = name.find_first_of ("[\"<]");
|
||||||
|
if (nextPos != string::npos)
|
||||||
|
name.erase (nextPos);
|
||||||
|
}
|
||||||
|
|
||||||
LOG ("plain name: " << name);
|
LOG ("plain name: " << name);
|
||||||
addPrevious (href, name);
|
addPrevious (href, name);
|
||||||
}
|
}
|
||||||
@ -281,6 +303,7 @@ MainAttachment::extractLinks (const string &extractedPlainKAZ) {
|
|||||||
// ================================================================================
|
// ================================================================================
|
||||||
void
|
void
|
||||||
MainAttachment::extractLinks (const vector<string> &liOne) {
|
MainAttachment::extractLinks (const vector<string> &liOne) {
|
||||||
|
// html text => "<li ...><a href="url">name</a>"
|
||||||
DEF_LOG ("Attachment::extractedPlainKAZ", "liOne.size: " << liOne.size ());
|
DEF_LOG ("Attachment::extractedPlainKAZ", "liOne.size: " << liOne.size ());
|
||||||
for (const string &one : liOne) {
|
for (const string &one : liOne) {
|
||||||
if (caseInsensitiveFind (one, CLASS_ONE) == string::npos)
|
if (caseInsensitiveFind (one, CLASS_ONE) == string::npos)
|
||||||
@ -353,17 +376,19 @@ MainAttachment::extractPreviousKAZ (ifstream &mbox) {
|
|||||||
void
|
void
|
||||||
MainAttachment::removePreviousArchive () {
|
MainAttachment::removePreviousArchive () {
|
||||||
vector<string> toRemove;
|
vector<string> toRemove;
|
||||||
for (map <string, string>::const_iterator it = previousLinks.begin (); it != previousLinks.end (); ++it)
|
for (map <string, string>::const_iterator it = previousLinks.begin (); it != previousLinks.end (); ++it) {
|
||||||
if (it->first.find ("&g=") != string::npos ||
|
const string key (it->first);
|
||||||
it->first.find ("&l=/") != string::npos) // v1 compatibility
|
if (regex_match (key, archiveURLSignature))
|
||||||
toRemove.push_back (it->first);
|
toRemove.push_back (key);
|
||||||
|
}
|
||||||
for (string old : toRemove)
|
for (string old : toRemove)
|
||||||
previousLinks.erase (old);
|
previousLinks.erase (old);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
MainAttachment::MainAttachment (ifstream &mbox)
|
MainAttachment::MainAttachment (ifstream &mbox)
|
||||||
: Attachment (mbox, initTmpLevel (), 0, initTmpPos ()) {
|
: Attachment (mbox, initTmpLevel (), 0, initTmpPos ()),
|
||||||
|
forceMainText (false) {
|
||||||
DEF_LOG ("MainAttachment::MainAttachment", "");
|
DEF_LOG ("MainAttachment::MainAttachment", "");
|
||||||
string line;
|
string line;
|
||||||
for (; getline (mbox, line); )
|
for (; getline (mbox, line); )
|
||||||
@ -377,6 +402,7 @@ MainAttachment::markSignificant (const streamoff &minAttachSize, ifstream &mbox)
|
|||||||
DEF_LOG ("MainAttachment::markSignificant", "minAttachSize: " << minAttachSize);
|
DEF_LOG ("MainAttachment::markSignificant", "minAttachSize: " << minAttachSize);
|
||||||
bool plainMarked (false), htmlMarked (false);
|
bool plainMarked (false), htmlMarked (false);
|
||||||
markDisclaim (plainMarked, htmlMarked);
|
markDisclaim (plainMarked, htmlMarked);
|
||||||
|
forceMainText = ! (plainMarked || htmlMarked);
|
||||||
Attachment::markSignificant ("", minAttachSize, mbox, allMarkedPtrs);
|
Attachment::markSignificant ("", minAttachSize, mbox, allMarkedPtrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +538,7 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
|||||||
}
|
}
|
||||||
if (attachP->cid.length ()) {
|
if (attachP->cid.length ()) {
|
||||||
string tmp (attachP->downloadUrl);
|
string tmp (attachP->downloadUrl);
|
||||||
replaceAll (tmp, "&", "&");
|
//replaceAll (tmp, "&", "&");
|
||||||
translateHtml.insert (pair<const string, const string> (CID+attachP->cid, tmp));
|
translateHtml.insert (pair<const string, const string> (CID+attachP->cid, tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -521,15 +547,31 @@ MainAttachment::substitute (ifstream &mbox, ofstream &outbox, const SizeArg &min
|
|||||||
continue;
|
continue;
|
||||||
for (EmbeddedData &embedded : attachP->embeddedData)
|
for (EmbeddedData &embedded : attachP->embeddedData)
|
||||||
readDownloadUrl (embedded.downloadUrl);
|
readDownloadUrl (embedded.downloadUrl);
|
||||||
|
// XXX test empty ?
|
||||||
}
|
}
|
||||||
readArchiveUrl ();
|
readArchiveUrl ();
|
||||||
|
removePreviousArchive ();
|
||||||
string plainDisclaim, htmlDisclaim;
|
string plainDisclaim, htmlDisclaim;
|
||||||
getDisclaim (plainDisclaim, htmlDisclaim);
|
getDisclaim (plainDisclaim, htmlDisclaim);
|
||||||
// copy email
|
// copy email
|
||||||
streamoff curPos = 0;
|
streamoff curPos = 0;
|
||||||
|
if (forceMainText) {
|
||||||
|
cerr << endl << endl << " #################### coucou " << forceMainText << " " << contentPos << " " << *this << endl;
|
||||||
|
// check no main text
|
||||||
|
LOG ("Force main text");
|
||||||
|
LOG_BUG (boundary.empty () || ! subAttachements.size (), /**/, "eMailShrinker: can't force add footer M9: : " << *this);
|
||||||
|
copy (mbox, outbox, curPos, contentPos);
|
||||||
|
curPos = contentPos;
|
||||||
|
cerr << " #################### coucou " << curPos << endl << endl;
|
||||||
|
string content (plainDisclaim);
|
||||||
|
base64Encode (content);
|
||||||
|
outbox << boundary.substr (0, boundary.length () -2) << endl
|
||||||
|
<< KAZ_EMPTY_TEXT_PLAIN << endl
|
||||||
|
<< content << endl;
|
||||||
|
outbox.flush ();
|
||||||
|
}
|
||||||
for (Attachment *attachP : allMarkedPtrs) {
|
for (Attachment *attachP : allMarkedPtrs) {
|
||||||
copy (mbox, outbox, curPos, attachP->beginInParent);
|
copy (mbox, outbox, curPos, attachP->beginInParent);
|
||||||
|
|
||||||
LOG_BUG (attachP->toUpdate && attachP->toExtract, /**/, "eMailShrinker: bug M5: update and extract. pos: " << attachP->beginPos);
|
LOG_BUG (attachP->toUpdate && attachP->toExtract, /**/, "eMailShrinker: bug M5: update and extract. pos: " << attachP->beginPos);
|
||||||
|
|
||||||
if (attachP->toExtract) {
|
if (attachP->toExtract) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// 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.0 2022-02-08 eMailShrinker"
|
#define LAST_VERSION "2.1 2022-10-30 eMailShrinker"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -188,10 +188,10 @@ main (int argc, char** argv) {
|
|||||||
MainAttachment attachment (mbox);
|
MainAttachment attachment (mbox);
|
||||||
mbox.close ();
|
mbox.close ();
|
||||||
|
|
||||||
if (attachment.getBoundary ().empty ()) {
|
// if (attachment.getBoundary ().empty ()) {
|
||||||
cerr << "no attachment" << endl;
|
// cerr << "no attachment" << endl;
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
// parse structure
|
// parse structure
|
||||||
mbox.open (inputName);
|
mbox.open (inputName);
|
||||||
attachment.markSignificant (minAttachSize, mbox);
|
attachment.markSignificant (minAttachSize, mbox);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// 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 "1.0 2021-02-21 jirafeauAPI"
|
#define LAST_VERSION "1.1 2022-10-30 jirafeauAPI"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -281,12 +281,13 @@ main (int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt (easyhandle, CURLOPT_MIMEPOST, multipart);
|
curl_easy_setopt (easyhandle, CURLOPT_MIMEPOST, multipart);
|
||||||
curl_easy_perform (easyhandle);
|
CURLcode res (curl_easy_perform (easyhandle));
|
||||||
curl_easy_cleanup (easyhandle);
|
curl_easy_cleanup (easyhandle);
|
||||||
cout << readBuffer << endl;
|
cout << readBuffer << endl;
|
||||||
|
|
||||||
showTime ("Upload");
|
showTime ("Upload");
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
cerr << prog << " failed: " << curl_easy_strerror (res) << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
#ifndef _kaz_Attachment_hpp
|
#ifndef _kaz_Attachment_hpp
|
||||||
#define _kaz_Attachment_hpp
|
#define _kaz_Attachment_hpp
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <regex>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "EmbeddedData.hpp"
|
#include "EmbeddedData.hpp"
|
||||||
|
@ -83,6 +83,8 @@ namespace kaz {
|
|||||||
bfs::path extractDir;
|
bfs::path extractDir;
|
||||||
/*! URL for download archives */
|
/*! URL for download archives */
|
||||||
string archiveDownloadURL;
|
string archiveDownloadURL;
|
||||||
|
/*! no main text in email can be use to add disclaim */
|
||||||
|
bool forceMainText;
|
||||||
|
|
||||||
/*! subset in the tree of all attachments to be consider for extraction or modification */
|
/*! subset in the tree of all attachments to be consider for extraction or modification */
|
||||||
vector<Attachment *> allMarkedPtrs;
|
vector<Attachment *> allMarkedPtrs;
|
||||||
|
Reference in New Issue
Block a user