diff --git a/src/Errors.h b/src/Errors.h index 38dd8ee30..551084fab 100644 --- a/src/Errors.h +++ b/src/Errors.h @@ -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 diff --git a/src/Http_Web.c b/src/Http_Web.c index c1e9b4084..3e51fc2c4 100644 --- a/src/Http_Web.c +++ b/src/Http_Web.c @@ -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 */ diff --git a/src/Logger.c b/src/Logger.c index 94d121790..1efdaf2d0 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -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; } diff --git a/src/interop_web.js b/src/interop_web.js index fdeddea8d..093b89203 100644 --- a/src/interop_web.js +++ b/src/interop_web.js @@ -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) {