mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-11 22:03:09 -06:00
Core/POP3: InetMessage fix
git-svn-id: svn://ultimatepp.org/upp/trunk@8017 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2abdefd5e5
commit
d13642ed47
4 changed files with 19 additions and 16 deletions
|
|
@ -12,7 +12,7 @@ String UrlDecode(const char *s, int len);
|
|||
String UrlDecode(const String& s);
|
||||
|
||||
String QPEncode(const char* s);
|
||||
String QPDecode(const char *s);
|
||||
String QPDecode(const char *s, bool undescore_to_space = false);
|
||||
|
||||
String Base64Encode(const char *s, const char *end);
|
||||
String Base64Encode(const char *s, int len);
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ String QPEncode(const char* s)
|
|||
int len = 0;
|
||||
const int limit = 70;
|
||||
while(*s) {
|
||||
if(s[0] >= 33 && s[0] <= 126 && s[0] != '=') {
|
||||
if(s[0] >= 33 && s[0] <= 126 && s[0] != '=' && s[0] != '_') {
|
||||
r.Cat(s[0]);
|
||||
len++;
|
||||
}
|
||||
|
|
@ -188,8 +188,8 @@ String QPEncode(const char* s)
|
|||
len = 0;
|
||||
}
|
||||
else // Encode HT or SP only if they are at the end of line (before CRLF or EOF)
|
||||
if((s[0] == ' ' || s[0] == '\t') &&
|
||||
(s[1] && s[1] != '\n') &&
|
||||
if((s[0] == ' ' || s[0] == '\t') &&
|
||||
(s[1] && s[1] != '\n') &&
|
||||
(s[1] != '\r' || (s[1] == '\r' && s[2] && s[2] != '\n'))) {
|
||||
r.Cat(s[0]);
|
||||
len++;
|
||||
|
|
@ -212,7 +212,7 @@ String QPEncode(const char* s)
|
|||
return r;
|
||||
}
|
||||
|
||||
String QPDecode(const char *s)
|
||||
String QPDecode(const char *s, bool underscore_to_space)
|
||||
{
|
||||
StringBuffer r;
|
||||
while(*s) {
|
||||
|
|
@ -226,6 +226,9 @@ String QPDecode(const char *s)
|
|||
if(IsXDigit(c1) && IsXDigit(c2))
|
||||
r.Cat((ctoi(c1) << 4) | ctoi(c2));
|
||||
}
|
||||
else
|
||||
if(underscore_to_space && c == '_')
|
||||
r.Cat(' ');
|
||||
else
|
||||
r.Cat(c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,12 @@ String QDecode(const String& s)
|
|||
return s;
|
||||
if(begin != "=" || end != "=")
|
||||
return s;
|
||||
if(ToUpper(enc) == "B")
|
||||
enc = ToUpper(enc);
|
||||
if(enc == "B")
|
||||
r = Base64Decode(txt);
|
||||
else
|
||||
if(ToUpper(enc) == "Q") {
|
||||
txt.Replace(" ", "_");
|
||||
r = QPDecode(txt);
|
||||
r.Replace("_", " ");
|
||||
}
|
||||
if(enc == "Q")
|
||||
r = QPDecode(txt, true);
|
||||
else
|
||||
return s;
|
||||
int charset = CharsetByName(chs);
|
||||
|
|
@ -88,7 +86,7 @@ String sEncode(const String& text)
|
|||
String txt = ToCharset(CHARSET_UTF8, text);
|
||||
String r = "=?UTF-8?Q?";
|
||||
for(const char *s = txt; *s; s++) {
|
||||
if((byte)*s < ' ' || (byte)*s > 127 || findarg(*s, '=', '?', ' ', ',') >= 0)
|
||||
if((byte)*s < ' ' || (byte)*s > 127 || findarg(*s, '=', '?', ' ', ',', '_') >= 0)
|
||||
r << '=' << FormatIntHexUpper((byte)*s, 2);
|
||||
else
|
||||
r.Cat(*s);
|
||||
|
|
|
|||
|
|
@ -59,13 +59,15 @@ IME type application/x`-www`-form`-urlencoded] (see UrlEncode).&]
|
|||
[s5;:QPEncode`(const char`*`): [_^String^ String]_[* QPEncode]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har`*]_[*@3 s])&]
|
||||
[s2;%% Encodes string to [^http`:`/`/en`.wikipedia`.org`/wiki`/Quoted`-printable^ quote
|
||||
d`-printable] format .&]
|
||||
d`-printable] format.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:QPDecode`(const char`*`): [_^String^ String]_[* QPDecode]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 s])&]
|
||||
[s5;:QPDecode`(const char`*`,bool`): [_^String^ String]_[* QPDecode]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 s], [@(0.0.255) bool]_[*@3 underscore`_to`_space]_`=_[@(0.0.255) false])&]
|
||||
[s2;%% Decodes string from [^http`:`/`/en`.wikipedia`.org`/wiki`/Quoted`-printable^ quo
|
||||
ted`-printable] format .&]
|
||||
ted`-printable] format. If [%-*@3 s] [%-*@3 underscore`_to`_space]
|
||||
is true, function replaces `'`_`' with space `' `' (as required
|
||||
by [^http`:`/`/en`.wikipedia`.org`/wiki`/MIME`#Encoded`-Word^ encoded`-word]).&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Base64Encode`(const char`*`,const char`*`): [_^String^ String]_[* Base64Encode]([@(0.0.255) c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue