This commit is contained in:
2023-10-29 17:03:58 +01:00
parent c2656fd377
commit 6afbaf1fb2
15 changed files with 359 additions and 461 deletions

View File

@ -125,7 +125,7 @@ Attachment::removeSection (string &content, const string &beginTag, const string
// ================================================================================
string
Attachment::getSection (const string &content, const string &beginTag, const string &endTag) {
DEF_LOG ("Attachment::getSection", "beginTag: " << beginTag << " endTag: " << endTag << " content: " << content);
DEF_LOG ("Attachment::getSection", "beginTag: " << beginTag << " endTag: " << endTag << " content: " << content.substr (0, 100) << "...");
vector<string> list;
getSection (content, beginTag, endTag, list);
size_t sum (0);
@ -142,18 +142,17 @@ Attachment::getSection (const string &content, const string &beginTag, const str
// ================================================================================
void
Attachment::getSection (const string &content, const string &beginTag, const string &endTag, vector<string> &result) {
DEF_LOG ("Attachment::getSection", "beginTag: " << beginTag << " endTag: " << endTag << " content: " << content);
DEF_LOG ("Attachment::getSection", "beginTag: " << beginTag << " endTag: " << endTag << " content: " << content.substr (0, 100) << "...");
for (string::size_type startPos (0);
(startPos = caseInsensitiveFind (content, beginTag, startPos)) != string::npos;
) {
LOG (beginTag << ": " << startPos);
string::size_type stopPos = caseInsensitiveFind (content, endTag, startPos);
LOG_BUG (stopPos == string::npos, break, "eMailShrinker: bug A3: " << endTag << " not found! at: " << startPos);
// LOG_BUG (stopPos == string::npos, break, "eMailShrinker: bug A3: " << endTag << " not found! at: " << startPos << endl << content);
LOG_BUG (stopPos == string::npos, break, "eMailShrinker: bug A3: " << endTag << " not found! at: " << startPos << endl << content.substr (0, 100) << "...");
LOG ("start: " << startPos << " stop: " << stopPos);
LOG_BUG (startPos == stopPos, /**/, "eMailShrinker: bug A4: " << endTag << " without " << beginTag << " at: " << startPos);
LOG_BUG (startPos == stopPos, /* */, "eMailShrinker: bug A4: " << endTag << " without " << beginTag << " at: " << startPos);
if (startPos != stopPos) {
startPos += beginTag.length ();
result.push_back (content.substr (startPos, stopPos-startPos));
@ -317,7 +316,7 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
if (line[0] == ' ' || line[0] == '\t') {
if (lastVar.empty ()) {
LOG_BUG (true, /**/, "eMailShrinker: bug A5: not compliant MIME. pos: " << (curPos - (line.length () + 1)) << " line: " << line);
LOG_BUG (true, /* */, "eMailShrinker: bug A5: not compliant MIME. pos: " << (curPos - (line.length () + 1)) << " line: " << line);
} else {
LOG ("add line to var: " << line);
env.find (lastVar)->second += cleanString (line);
@ -500,7 +499,7 @@ Attachment::getContent (ifstream &mbox) const {
// ================================================================================
void
Attachment::println (ofstream &outbox, string content) const {
DEF_LOG ("Attachment::println", "content: " << content);
DEF_LOG ("Attachment::println", "content: " << content.substr (0, 100) << "...");
if (isBase64Encoding ())
base64Encode (content);
if (isQuotedPrintableEnconding ())