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

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