No longer assume that a QR filename contains a quote (Fixes #204)

This commit is contained in:
Dylan G
2020-06-12 16:27:40 +01:00
parent 2c2c7f4b33
commit f819f9d452
2 changed files with 13 additions and 4 deletions

View File

@@ -29,6 +29,7 @@
#include "common.h" #include "common.h"
#include "draw.h" #include "draw.h"
#include <ctype.h>
#define THEMEPLAZA_BASE_URL "https://themeplaza.eu" #define THEMEPLAZA_BASE_URL "https://themeplaza.eu"
#define THEMEPLAZA_API_URL "/api/anemone/v1" #define THEMEPLAZA_API_URL "/api/anemone/v1"

View File

@@ -807,10 +807,7 @@ u32 http_get(const char *url, char ** filename, char ** buf, InstallType install
return 0; return 0;
} }
DEBUG(content_disposition); char * tok = strstr(content_disposition, "filename=");
char * tok = strtok(content_disposition, "\"");
DEBUG(tok);
tok = strtok(NULL, "\"");
if(!(tok)) if(!(tok))
{ {
@@ -822,6 +819,17 @@ u32 http_get(const char *url, char ** filename, char ** buf, InstallType install
return 0; 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 = "\"?;:/\\+"; char *illegal_characters = "\"?;:/\\+";
for (size_t i = 0; i < strlen(tok); i++) for (size_t i = 0; i < strlen(tok); i++)
{ {