diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-21 15:59:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-21 15:59:56 +0300 |
commit | d30afe819abb03b139190c020db271888fab5eb1 (patch) | |
tree | ded6ed9860a4ea622a08450113400f9cbf9f47e9 /src/mir_core | |
parent | d78ec3edaa1f6c3d6cb80aa2767a38afda76bc25 (diff) |
attempt to unify AsyncHttpRequest in various protocols
Diffstat (limited to 'src/mir_core')
-rwxr-xr-x | src/mir_core/src/http.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/mir_core/src/http.cpp b/src/mir_core/src/http.cpp index ae5a9f3ff4..fad969c680 100755 --- a/src/mir_core/src/http.cpp +++ b/src/mir_core/src/http.cpp @@ -29,11 +29,14 @@ MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl) const BYTE *s;
int outputLen;
for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++) {
- if (('0' <= *s && *s <= '9') || //0-9
+ if ((*s & 0x80) ||
+ ('0' <= *s && *s <= '9') || //0-9
('A' <= *s && *s <= 'Z') || //ABC...XYZ
('a' <= *s && *s <= 'z') || //abc...xyz
- *s == '-' || *s == '_' || *s == '.' || *s == ' ' || *s == '~') outputLen++;
- else outputLen += 3;
+ *s == '-' || *s == '_' || *s == '.' || *s == ' ' || *s == '~')
+ outputLen++;
+ else
+ outputLen += 3;
}
char *szOutput = (char*)mir_alloc(outputLen+1);
@@ -42,11 +45,17 @@ MIR_CORE_DLL(char*) mir_urlEncode(const char *szUrl) char *d = szOutput;
for (s = (const BYTE*)szUrl; *s; s++) {
- if (('0' <= *s && *s <= '9') || //0-9
- ('A' <= *s && *s <= 'Z') || //ABC...XYZ
- ('a' <= *s && *s <= 'z') || //abc...xyz
- *s == '-' || *s == '_' || *s == '.' || *s == '~') *d++ = *s;
- else if (*s == ' ') *d++='+';
+ if ((*s & 0x80) ||
+ ('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '-' || *s == '_' || *s == '.' || *s == '~')
+ {
+ *d++ = *s;
+ }
+ else if (*s == ' ') {
+ *d++ = '+';
+ }
else {
*d++ = '%';
*d++ = szHexDigits[*s >> 4];
|