Reduce indent by 3 levels in findNextBoundary

This commit is contained in:
Jan Engelhardt 2019-10-04 21:53:04 +02:00
parent 6de75f0c95
commit c9119effd7

View File

@ -65,7 +65,7 @@ size_t body::findNextBoundaryPosition(
size_t pos = position;
while (pos != npos && pos < end) {
for (; pos != npos && pos < end; ++pos) {
pos = parser->findNext(boundary, pos);
@ -73,7 +73,10 @@ size_t body::findNextBoundaryPosition(
break; // not found
}
if (pos != 0) {
if (pos == 0) {
// Boundary is a prefix of another, continue the search (same for the other "continue"s)
continue;
}
// Skip transport padding bytes (SPACE or HTAB), if any
size_t advance = 0;
@ -93,18 +96,24 @@ size_t body::findNextBoundaryPosition(
// Ensure the bytes before boundary are "[LF]--": boundary should be
// at the beginning of a line, and should start with "--"
if (pos - advance >= 3) {
if (pos - advance < 3) {
continue;
}
parser->seek(pos - advance - 3);
if (parser->matchBytes("\n--", 3)) {
if (!parser->matchBytes("\n--", 3)) {
continue;
}
parser->seek(pos + boundary.length());
const byte_t next = parser->peekByte();
// Boundary should be followed by a new line or a dash
if (next == '\r' || next == '\n' || next == '-') {
if (next != '\r' && next != '\n' && next != '-') {
continue;
}
// Get rid of the "[CR]" just before "[LF]--", if any
if (pos - advance >= 4) {
@ -121,13 +130,6 @@ size_t body::findNextBoundaryPosition(
return pos;
}
}
}
}
// Boundary is a prefix of another, continue the search
pos++;
}
return pos;
}