mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Fix passwords with some non alphanumeric characters not working
This commit is contained in:
parent
41b4faa6a1
commit
03a264bd91
@ -104,6 +104,11 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
|
|||||||
#define CC_BUILD_X11
|
#define CC_BUILD_X11
|
||||||
#define CC_BUILD_POSIX
|
#define CC_BUILD_POSIX
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#define CC_BUILD_WEB
|
||||||
|
#define CC_BUILD_SDL
|
||||||
|
#define CC_BUILD_POSIX
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CC_BUILD_D3D9
|
#ifdef CC_BUILD_D3D9
|
||||||
|
35
src/Http.c
35
src/Http.c
@ -740,6 +740,41 @@ static void Http_WorkerLoop(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*########################################################################################################################*
|
||||||
|
*-------------------------------------------------------Http misc---------------------------------------------------------*
|
||||||
|
*#########################################################################################################################*/
|
||||||
|
static bool Http_UrlDirect(uint8_t c) {
|
||||||
|
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')
|
||||||
|
|| c == '-' || c == '_' || c == '.' || c == '~';
|
||||||
|
}
|
||||||
|
|
||||||
|
void Http_UrlEncode(String* dst, const uint8_t* data, int len) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
uint8_t c = data[i];
|
||||||
|
|
||||||
|
if (Http_UrlDirect(c)) {
|
||||||
|
String_Append(dst, c);
|
||||||
|
} else {
|
||||||
|
String_Append(dst, '%');
|
||||||
|
String_AppendHex(dst, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Http_UrlEncodeUtf8(String* dst, const String* src) {
|
||||||
|
uint8_t data[4];
|
||||||
|
Codepoint cp;
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
for (i = 0; i < src->length; i++) {
|
||||||
|
cp = Convert_CP437ToUnicode(src->buffer[i]);
|
||||||
|
len = Convert_UnicodeToUtf8(cp, data);
|
||||||
|
Http_UrlEncode(dst, data, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Http component------------------------------------------------------*
|
*-----------------------------------------------------Http component------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
@ -55,6 +55,11 @@ void Http_AsyncPostData(const String* url, bool priority, const String* id, cons
|
|||||||
/* Also sets the If-Modified-Since and If-None-Match headers. (if not NULL) */
|
/* Also sets the If-Modified-Since and If-None-Match headers. (if not NULL) */
|
||||||
void Http_AsyncGetDataEx(const String* url, bool priority, const String* id, TimeMS* lastModified, const String* etag);
|
void Http_AsyncGetDataEx(const String* url, bool priority, const String* id, TimeMS* lastModified, const String* etag);
|
||||||
|
|
||||||
|
/* Encodes data using % or URL encoding. */
|
||||||
|
void Http_UrlEncode(String* dst, const uint8_t* data, int len);
|
||||||
|
/* Converts characters to UTF8, then calls Http_URlEncode on them. */
|
||||||
|
void Http_UrlEncodeUtf8(String* dst, const String* src);
|
||||||
|
|
||||||
/* Attempts to retrieve a fully completed request. */
|
/* Attempts to retrieve a fully completed request. */
|
||||||
/* NOTE: You MUST also check Result/StatusCode, and check Size is > 0. */
|
/* NOTE: You MUST also check Result/StatusCode, and check Size is > 0. */
|
||||||
/* (because a completed request may not have completed successfully) */
|
/* (because a completed request may not have completed successfully) */
|
||||||
|
13
src/LWeb.c
13
src/LWeb.c
@ -286,10 +286,15 @@ static void SignInTask_Handle(uint8_t* data, uint32_t len) {
|
|||||||
Json_Handle(data, len, SignInTask_OnValue, NULL, NULL);
|
Json_Handle(data, len, SignInTask_OnValue, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SignInTask_Append(String* dst, const char* key, const String* value) {
|
||||||
|
String_AppendConst(dst, key);
|
||||||
|
Http_UrlEncodeUtf8(dst, value);
|
||||||
|
}
|
||||||
|
|
||||||
void SignInTask_Run(const String* user, const String* pass) {
|
void SignInTask_Run(const String* user, const String* pass) {
|
||||||
const static String id = String_FromConst("CC post login");
|
const static String id = String_FromConst("CC post login");
|
||||||
const static String url = String_FromConst("https://www.classicube.net/api/login");
|
const static String url = String_FromConst("https://www.classicube.net/api/login");
|
||||||
String tmp; char tmpBuffer[STRING_SIZE * 5];
|
String tmp; char tmpBuffer[STRING_SIZE * 6];
|
||||||
if (SignInTask.Base.Working) return;
|
if (SignInTask.Base.Working) return;
|
||||||
|
|
||||||
LWebTask_Reset(&SignInTask.Base);
|
LWebTask_Reset(&SignInTask.Base);
|
||||||
@ -297,9 +302,9 @@ void SignInTask_Run(const String* user, const String* pass) {
|
|||||||
SignInTask.Error.length = 0;
|
SignInTask.Error.length = 0;
|
||||||
|
|
||||||
String_InitArray(tmp, tmpBuffer);
|
String_InitArray(tmp, tmpBuffer);
|
||||||
/* TODO: URL ENCODE THIS.. */
|
SignInTask_Append(&tmp, "username=", user);
|
||||||
String_Format3(&tmp, "username=%s&password=%s&token=%s",
|
SignInTask_Append(&tmp, "&password=", pass);
|
||||||
user, pass, &GetTokenTask.Token);
|
SignInTask_Append(&tmp, "&token=", &GetTokenTask.Token);
|
||||||
|
|
||||||
SignInTask.Base.Identifier = id;
|
SignInTask.Base.Identifier = id;
|
||||||
Http_AsyncPostData(&url, false, &id, tmp.buffer, tmp.length);
|
Http_AsyncPostData(&url, false, &id, tmp.buffer, tmp.length);
|
||||||
|
@ -626,7 +626,6 @@ static void Launcher_ApplyUpdate(void) {
|
|||||||
res = Platform_MarkExecutable(&scriptPath);
|
res = Platform_MarkExecutable(&scriptPath);
|
||||||
if (res) Logger_Warn(res, "making update script executable");
|
if (res) Logger_Warn(res, "making update script executable");
|
||||||
|
|
||||||
/* TODO: (open -a Terminal ", '"' + path + '"'); on OSX */
|
|
||||||
res = Platform_StartProcess(&scriptName, &scriptArgs);
|
res = Platform_StartProcess(&scriptName, &scriptArgs);
|
||||||
if (res) { Logger_Warn(res, "starting update script"); return; }
|
if (res) { Logger_Warn(res, "starting update script"); return; }
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,10 @@ const ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
|
|||||||
#include <OpenAL/alc.h>
|
#include <OpenAL/alc.h>
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_BUILD_WEB
|
||||||
|
#include <emscripten.h>
|
||||||
|
#include <AL/al.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -368,6 +372,12 @@ uint64_t Stopwatch_Measure(void) {
|
|||||||
return mach_absolute_time();
|
return mach_absolute_time();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_BUILD_WEB
|
||||||
|
uint64_t Stopwatch_Measure(void) {
|
||||||
|
/* time is a milliseconds double */
|
||||||
|
return (uint64_t)(emscripten_get_now() * 1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -1956,6 +1966,13 @@ ReturnCode Platform_GetExePath(String* path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CC_BUILD_WEB
|
||||||
|
ReturnCode Platform_StartOpen(const String* args) {
|
||||||
|
char str[600];
|
||||||
|
Platfrom_ConvetString(args, str);
|
||||||
|
EM_ASM_({ window.open(Pointer_stringify($0)); }, str);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* Platform_GetSymbolFrom(const char* filename, const char* name) {
|
void* Platform_GetSymbolFrom(const char* filename, const char* name) {
|
||||||
void* symbol;
|
void* symbol;
|
||||||
|
@ -166,6 +166,7 @@ bool Convert_TryUnicodeToCP437(Codepoint cp, char* c);
|
|||||||
/* Returns 0 if not enough input data to read the character. */
|
/* Returns 0 if not enough input data to read the character. */
|
||||||
int Convert_Utf8ToUnicode(Codepoint* cp, const uint8_t* data, uint32_t len);
|
int Convert_Utf8ToUnicode(Codepoint* cp, const uint8_t* data, uint32_t len);
|
||||||
/* Encodes a unicode character in UTF8, returning number of bytes written. */
|
/* Encodes a unicode character in UTF8, returning number of bytes written. */
|
||||||
|
/* The number of bytes written is always either 1,2 or 3. */
|
||||||
int Convert_UnicodeToUtf8(Codepoint cp, uint8_t* data);
|
int Convert_UnicodeToUtf8(Codepoint cp, uint8_t* data);
|
||||||
|
|
||||||
/* Attempts to append all characters from UTF16 encoded data to the given string. */
|
/* Attempts to append all characters from UTF16 encoded data to the given string. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user