diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-10 19:44:33 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-10 19:44:33 +0300 |
commit | 3ed330e2f9a5239044ede720894fe25ca1d675c7 (patch) | |
tree | c1be5b6c4f1fe32e70eca86424b2ab6c0267fd81 /protocols/YAMN/src/mails/decode.cpp | |
parent | ee35b17e21bc5e4388e47c6af1c9736af910d306 (diff) |
fixes #3728 (YAMN: украинские символы отображаются некорректно)
Diffstat (limited to 'protocols/YAMN/src/mails/decode.cpp')
-rw-r--r-- | protocols/YAMN/src/mails/decode.cpp | 38 |
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;
|