mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Webclient: Fix trying to click invalid urls in chat causing game crash message to appear
Although the game itself would keep working in this case
This commit is contained in:
parent
64ad1a5f0d
commit
9fda93eaac
@ -112,6 +112,7 @@ enum CC_ERRORS {
|
||||
|
||||
ERR_DOWNLOAD_INVALID = 0xCCDED05CUL, /* Unspecified error occurred downloading data */
|
||||
ERR_NO_AUDIO_OUTPUT = 0xCCDED05DUL, /* No audio output devices are connected */
|
||||
ERR_INVALID_URL = 0xCCDED05EUL /* Invalid URL provided to download from */
|
||||
ERR_INVALID_DATA_URL = 0xCCDED05EUL, /* Invalid URL provided to download from */
|
||||
ERR_INVALID_OPEN_URL = 0xCCDED05FUL, /* Invalid URL provided to open in new tab */
|
||||
};
|
||||
#endif
|
||||
|
@ -70,8 +70,8 @@ static void Http_StartNextDownload(void) {
|
||||
res = interop_DownloadAsync(urlStr, req->requestType, req->id);
|
||||
|
||||
if (res) {
|
||||
/* Download error code -> ClassiCube error code */
|
||||
if (res == 1) res = ERR_INVALID_URL;
|
||||
/* interop error code -> ClassiCube error code */
|
||||
if (res == 1) res = ERR_INVALID_DATA_URL;
|
||||
req->result = res;
|
||||
|
||||
/* Invalid URL so move onto next request */
|
||||
|
@ -82,7 +82,8 @@ static const char* GetCCErrorDesc(cc_result res) {
|
||||
|
||||
case ERR_DOWNLOAD_INVALID: return "Website denied download or doesn't exist";
|
||||
case ERR_NO_AUDIO_OUTPUT: return "No audio output devices plugged in";
|
||||
case ERR_INVALID_URL: return "Cannot download from invalid URL";
|
||||
case ERR_INVALID_DATA_URL: return "Cannot download from invalid URL";
|
||||
case ERR_INVALID_OPEN_URL: return "Cannot navigate to invalid URL";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -120,7 +120,14 @@ mergeInto(LibraryManager.library, {
|
||||
//---------------------------------------------------------Platform-------------------------------------------------------
|
||||
//########################################################################################################################
|
||||
interop_OpenTab: function(url) {
|
||||
window.open(UTF8ToString(url));
|
||||
try {
|
||||
window.open(UTF8ToString(url));
|
||||
} catch (e) {
|
||||
// DOMException gets thrown when invalid URL provided. Test cases:
|
||||
// http://example:app/test.zip
|
||||
console.log(e);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
interop_Log: function(msg, len) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user