|
a/src/bincimapmime/mime-parsefull.cc |
|
b/src/bincimapmime/mime-parsefull.cc |
|
... |
|
... |
304 |
}
|
304 |
}
|
305 |
|
305 |
|
306 |
bool Binc::MimePart::skipUntilBoundary(const string &delimiter,
|
306 |
bool Binc::MimePart::skipUntilBoundary(const string &delimiter,
|
307 |
unsigned int *nlines, bool *eof)
|
307 |
unsigned int *nlines, bool *eof)
|
308 |
{
|
308 |
{
|
309 |
int endpos = delimiter.length();
|
309 |
string::size_type endpos = delimiter.length();
|
310 |
char *delimiterqueue = 0;
|
310 |
char *delimiterqueue = 0;
|
311 |
int delimiterpos = 0;
|
311 |
string::size_type delimiterpos = 0;
|
312 |
const char *delimiterStr = delimiter.c_str();
|
312 |
const char *delimiterStr = delimiter.c_str();
|
313 |
if (delimiter != "") {
|
313 |
if (delimiter != "") {
|
314 |
delimiterqueue = new char[endpos];
|
314 |
delimiterqueue = new char[endpos];
|
315 |
memset(delimiterqueue, 0, endpos);
|
315 |
memset(delimiterqueue, 0, endpos);
|
316 |
}
|
316 |
}
|
|
... |
|
... |
338 |
delimiterqueue[delimiterpos++] = c;
|
338 |
delimiterqueue[delimiterpos++] = c;
|
339 |
if (delimiterpos == endpos)
|
339 |
if (delimiterpos == endpos)
|
340 |
delimiterpos = 0;
|
340 |
delimiterpos = 0;
|
341 |
|
341 |
|
342 |
if (compareStringToQueue(delimiterStr, delimiterqueue,
|
342 |
if (compareStringToQueue(delimiterStr, delimiterqueue,
|
343 |
delimiterpos, endpos)) {
|
343 |
delimiterpos, int(endpos))) {
|
344 |
foundBoundary = true;
|
344 |
foundBoundary = true;
|
345 |
break;
|
345 |
break;
|
346 |
}
|
346 |
}
|
347 |
}
|
347 |
}
|
348 |
|
348 |
|
|
... |
|
... |
449 |
string delimiter = "--" + boundary;
|
449 |
string delimiter = "--" + boundary;
|
450 |
|
450 |
|
451 |
skipUntilBoundary(delimiter, nlines, eof);
|
451 |
skipUntilBoundary(delimiter, nlines, eof);
|
452 |
|
452 |
|
453 |
if (!eof)
|
453 |
if (!eof)
|
454 |
*boundarysize = delimiter.size();
|
454 |
*boundarysize = int(delimiter.size());
|
455 |
|
455 |
|
456 |
postBoundaryProcessing(eof, nlines, boundarysize, foundendofpart);
|
456 |
postBoundaryProcessing(eof, nlines, boundarysize, foundendofpart);
|
457 |
|
457 |
|
458 |
// read all mime parts.
|
458 |
// read all mime parts.
|
459 |
if (!*foundendofpart && !*eof) {
|
459 |
if (!*foundendofpart && !*eof) {
|
|
... |
|
... |
482 |
// not have to start with CRLF.
|
482 |
// not have to start with CRLF.
|
483 |
string delimiter = "\r\n--" + toboundary;
|
483 |
string delimiter = "\r\n--" + toboundary;
|
484 |
skipUntilBoundary(delimiter, nlines, eof);
|
484 |
skipUntilBoundary(delimiter, nlines, eof);
|
485 |
|
485 |
|
486 |
if (!*eof)
|
486 |
if (!*eof)
|
487 |
*boundarysize = delimiter.size();
|
487 |
*boundarysize = int(delimiter.size());
|
488 |
|
488 |
|
489 |
postBoundaryProcessing(eof, nlines, boundarysize, foundendofpart);
|
489 |
postBoundaryProcessing(eof, nlines, boundarysize, foundendofpart);
|
490 |
}
|
490 |
}
|
491 |
|
491 |
|
492 |
// make sure bodylength doesn't overflow
|
492 |
// make sure bodylength doesn't overflow
|
|
... |
|
... |
526 |
|
526 |
|
527 |
// if (skipUntilBoundary(_toboundary, nlines, eof))
|
527 |
// if (skipUntilBoundary(_toboundary, nlines, eof))
|
528 |
// *boundarysize = _toboundary.length();
|
528 |
// *boundarysize = _toboundary.length();
|
529 |
|
529 |
|
530 |
char *boundaryqueue = 0;
|
530 |
char *boundaryqueue = 0;
|
531 |
int endpos = _toboundary.length();
|
531 |
size_t endpos = _toboundary.length();
|
532 |
if (toboundary != "") {
|
532 |
if (toboundary != "") {
|
533 |
boundaryqueue = new char[endpos];
|
533 |
boundaryqueue = new char[endpos];
|
534 |
memset(boundaryqueue, 0, endpos);
|
534 |
memset(boundaryqueue, 0, endpos);
|
535 |
}
|
535 |
}
|
536 |
|
536 |
|
|
... |
|
... |
538 |
|
538 |
|
539 |
const char *_toboundaryStr = _toboundary.c_str();
|
539 |
const char *_toboundaryStr = _toboundary.c_str();
|
540 |
string line;
|
540 |
string line;
|
541 |
bool toboundaryIsEmpty = (toboundary == "");
|
541 |
bool toboundaryIsEmpty = (toboundary == "");
|
542 |
char c;
|
542 |
char c;
|
543 |
int boundarypos = 0;
|
543 |
string::size_type boundarypos = 0;
|
544 |
while (mimeSource->getChar(&c)) {
|
544 |
while (mimeSource->getChar(&c)) {
|
545 |
if (c == '\n') { ++*nbodylines; ++*nlines; }
|
545 |
if (c == '\n') { ++*nbodylines; ++*nlines; }
|
546 |
|
546 |
|
547 |
if (toboundaryIsEmpty)
|
547 |
if (toboundaryIsEmpty)
|
548 |
continue;
|
548 |
continue;
|
|
... |
|
... |
551 |
boundaryqueue[boundarypos++] = c;
|
551 |
boundaryqueue[boundarypos++] = c;
|
552 |
if (boundarypos == endpos)
|
552 |
if (boundarypos == endpos)
|
553 |
boundarypos = 0;
|
553 |
boundarypos = 0;
|
554 |
|
554 |
|
555 |
if (compareStringToQueue(_toboundaryStr, boundaryqueue,
|
555 |
if (compareStringToQueue(_toboundaryStr, boundaryqueue,
|
556 |
boundarypos, endpos)) {
|
556 |
boundarypos, int(endpos))) {
|
557 |
*boundarysize = _toboundary.length();
|
557 |
*boundarysize = static_cast<int>(_toboundary.length());
|
558 |
break;
|
558 |
break;
|
559 |
}
|
559 |
}
|
560 |
}
|
560 |
}
|
561 |
|
561 |
|
562 |
delete [] boundaryqueue;
|
562 |
delete [] boundaryqueue;
|