diff --git a/include/remote.h b/include/remote.h index afc5865..acea822 100644 --- a/include/remote.h +++ b/include/remote.h @@ -29,6 +29,7 @@ #include "common.h" #include "draw.h" +#include #define THEMEPLAZA_BASE_URL "https://themeplaza.eu" #define THEMEPLAZA_API_URL "/api/anemone/v1" diff --git a/source/remote.c b/source/remote.c index dc5ee6e..5c6cd08 100644 --- a/source/remote.c +++ b/source/remote.c @@ -807,10 +807,7 @@ u32 http_get(const char *url, char ** filename, char ** buf, InstallType install return 0; } - DEBUG(content_disposition); - char * tok = strtok(content_disposition, "\""); - DEBUG(tok); - tok = strtok(NULL, "\""); + char * tok = strstr(content_disposition, "filename="); if(!(tok)) { @@ -822,6 +819,17 @@ u32 http_get(const char *url, char ** filename, char ** buf, InstallType install return 0; } + tok += sizeof("filename=") - 1; + if(ispunct((int)*tok)) + { + tok++; + } + char* last_char = tok + strlen(tok) - 1; + if(ispunct((int)*last_char)) + { + *last_char = '\0'; + } + char *illegal_characters = "\"?;:/\\+"; for (size_t i = 0; i < strlen(tok); i++) {