diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-10-26 11:26:56 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-10-26 11:26:56 +0000 |
commit | 903450d45350580131dc5acdf02b42d719d4650d (patch) | |
tree | da69c9b573f41367a2757054c715844ebb934035 /src/htsname.c | |
parent | f967595e08d5b75ef91a22a7d5faca588495cf9d (diff) |
Fixed type mishandling when processing a redirect (such as a .PDF redirecting to another .PDF, with a text/html type tagged in the redirect message) by ignoring MIME and content-disposition for redirect responses.
Diffstat (limited to 'src/htsname.c')
-rw-r--r-- | src/htsname.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/htsname.c b/src/htsname.c index 7683d6b..f480dde 100644 --- a/src/htsname.c +++ b/src/htsname.c @@ -146,10 +146,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, hash_struct * hash, int ptr, int numero_passe, const lien_back * headers) { char catbuff[CATBUFF_SIZE]; - const char *mime_type = (headers - && !HTTP_IS_REDIRECT(headers->r. - statuscode)) ? headers->r. - contenttype : NULL; + const int is_redirect = headers != NULL && HTTP_IS_REDIRECT(headers->r.statuscode); + const char *mime_type = headers != NULL && !is_redirect ? headers->r.contenttype : NULL; /*const char* mime_type = ( headers && HTTP_IS_OK(headers->r.statuscode) ) ? headers->r.contenttype : NULL; */ lien_back *const back = sback->lnk; @@ -374,14 +372,16 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, s[0] = '\0'; hts_log_print(opt, LOG_DEBUG, "Testing link type (from cache) %s%s", adr_complete, fil_complete); - if (strnotempty(r.cdispo)) { /* filename given */ - ext_chg = 2; /* change filename */ - strcpybuff(ext, r.cdispo); - } else if (!may_unknown2(opt, r.contenttype, fil)) { // on peut patcher à priori? - give_mimext(s, r.contenttype); // obtenir extension - if (strnotempty(s) > 0) { // on a reconnu l'extension - ext_chg = 1; - strcpybuff(ext, s); + if (!HTTP_IS_REDIRECT(r.statuscode)) { + if (strnotempty(r.cdispo)) { /* filename given */ + ext_chg = 2; /* change filename */ + strcpybuff(ext, r.cdispo); + } else if (!may_unknown2(opt, r.contenttype, fil)) { // on peut patcher à priori? + give_mimext(s, r.contenttype); // obtenir extension + if (strnotempty(s) > 0) { // on a reconnu l'extension + ext_chg = 1; + strcpybuff(ext, s); + } } } #ifdef DEFAULT_BIN_EXT @@ -413,7 +413,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, else if (opt->savename_delayed != 0 && !opt->state.stop) { // Check if the file is ready in backing. We basically take the same logic as later. // FIXME: we should cleanup and factorize this unholy mess - if (headers != NULL && headers->status >= 0) { + if (headers != NULL && headers->status >= 0 && !is_redirect) { if (strnotempty(headers->r.cdispo)) { /* filename given */ ext_chg = 2; /* change filename */ strcpybuff(ext, headers->r.cdispo); |