From 4720a49923b7ca1658cffeb9f8b85ad54180bf8b Mon Sep 17 00:00:00 2001 From: Dylan G <1565516+Helloman892@users.noreply.github.com> Date: Thu, 24 Dec 2020 22:58:52 +0000 Subject: [PATCH] QoL: alert the user if they attempt to download a theme that has not been approved. Stopgap solution; TP does not want to expose approval status in headers for security reasons. --- source/remote.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/remote.c b/source/remote.c index 571d25a..f12ee1b 100644 --- a/source/remote.c +++ b/source/remote.c @@ -1002,11 +1002,15 @@ redirect: // goto here if we need to redirect return _header.result_code; case HTTP_NOT_FOUND: case HTTP_GONE: ; - // TODO: check if we're looking at a TP URL, if we are, suggest that it might be missing const char * http_error = parse == HTTP_NOT_FOUND ? "404 Not Found" : "410 Gone"; DEBUG("HTTP %s; URL: %s\n", http_error, url); - snprintf(err_buf, 0x69, "HTTP %s\nCheck that the URL is correct.", http_error); - throw_error(err_buf, ERROR_LEVEL_WARNING); + if (strstr(url, THEMEPLAZA_BASE_URL) && parse == HTTP_NOT_FOUND) + throw_error("HTTP 404 Not Found\nHas this theme been approved?", ERROR_LEVEL_WARNING); + else + { + snprintf(err_buf, 0x69, "HTTP %s\nCheck that the URL is correct.", http_error); + throw_error(err_buf, ERROR_LEVEL_WARNING); + } return httpcCloseContext(&context); case HTTP_UNAUTHORIZED: case HTTP_FORBIDDEN: @@ -1021,7 +1025,7 @@ redirect: // goto here if we need to redirect return httpcCloseContext(&context); case HTTP_URI_TOO_LONG: DEBUG("HTTP 414; URL is too long, maybe too many redirects?\n"); - throw_error("HTTP 414 URI Too Long\nThe QR code points to a really long URL.\nContact the site administrator.", ERROR_LEVEL_WARNING); + throw_error("HTTP 414 URI Too Long\nThe QR code points to a really long URL.\nDownload the file directly.", ERROR_LEVEL_WARNING); return httpcCloseContext(&context); case HTTP_IM_A_TEAPOT: DEBUG("HTTP 418 I'm a teapot\n");