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:
UnknownShadow200 2022-01-05 13:06:37 +11:00
parent 64ad1a5f0d
commit 9fda93eaac
4 changed files with 14 additions and 5 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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;
}

View File

@ -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) {