summaryrefslogtreecommitdiff
path: root/protocols/YAMN/src/mails/decode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/YAMN/src/mails/decode.cpp')
-rw-r--r--protocols/YAMN/src/mails/decode.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/protocols/YAMN/src/mails/decode.cpp b/protocols/YAMN/src/mails/decode.cpp
index 0a2abb260e..8d8b9e7324 100644
--- a/protocols/YAMN/src/mails/decode.cpp
+++ b/protocols/YAMN/src/mails/decode.cpp
@@ -242,37 +242,39 @@ int DecodeQuotedPrintable(char *Src, char *Dst, int DstLen, BOOL isQ)
DebugLog(DecodeFile, "<Decode Quoted><Input>%s</Input>", Src);
#endif
- for (int Counter = 0; (*Src != 0) && DstLen && (Counter++ < DstLen); Src++, Dst++) {
+ for (auto *Limit = Dst + DstLen; *Src != 0 && Dst < Limit; Src++) {
if (*Src == '=') {
+ Src++;
+ if (*Src == 0)
+ break;
+
if (!isQ) {
- if (Src[1] == '\r') {
- Src++; Src++;
- if (Src[0] == '\n')
+ if (*Src == '\r') {
+ if (Src[1] == '\n')
Src++;
- goto CopyCharQuotedPrintable;
- }
- if (Src[1] == '\n') {
- Src++; Src++;
- goto CopyCharQuotedPrintable;
+ continue;
}
+
+ if (*Src == '\n')
+ continue;
}
+
char First, Second;
- if (!FromHexa(*(++Src), &First)) {
- *Dst++ = '='; Src--;
+ if (!FromHexa(Src[0], &First)) {
+ *Dst++ = '=';
continue;
}
- if (!FromHexa(*(++Src), &Second)) {
- *Dst++ = '='; Src--; Src--;
+ if (!FromHexa(Src[1], &Second)) {
+ *Dst++ = '='; Src--;
continue;
}
- *Dst = (char)(First) << 4;
- *Dst += Second;
+ *Dst++ = ((char)(First) << 4) + Second;
+ Src++;
}
else if (isQ && *Src == '_')
- *Dst = ' ';
+ *Dst++ = ' ';
else
-CopyCharQuotedPrintable:
- *Dst = *Src;
+ *Dst++ = *Src;
}
*Dst = 0;