Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
webui: implement Content-Disposition RFC2231 for filename, fixes #2960
  • Loading branch information
perexg committed Jun 22, 2015
1 parent 1396f62 commit 1b261af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/webui/webui.c
Expand Up @@ -45,6 +45,7 @@
#include "config.h"
#include "atomic.h"
#include "lang_codes.h"
#include "intlconv.h"
#if ENABLE_MPEGTS
#include "input.h"
#endif
Expand Down Expand Up @@ -1157,7 +1158,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
dvr_entry_t *de;
char *fname;
char *basename;
char *str;
char *str, *str0;
char range_buf[255];
char disposition[256];
off_t content_len, chunk;
Expand Down Expand Up @@ -1203,12 +1204,17 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
basename = strrchr(fname, '/');
if (basename) {
basename++; /* Skip '/' */
str0 = intlconv_utf8safestr(intlconv_charset_id("ASCII", 1, 1),
basename, strlen(basename) * 2);
htsbuf_queue_init(&q, 0);
htsbuf_append_and_escape_url(&q, basename);
str = htsbuf_to_string(&q);
snprintf(disposition, sizeof(disposition), "attachment; filename=\"%s\"", str);
snprintf(disposition, sizeof(disposition),
"attachment; filename=\"%s\"; filename*=utf-8''%s",
str0, str);
htsbuf_queue_flush(&q);
free(str);
free(str0);
} else {
disposition[0] = 0;
}
Expand Down

0 comments on commit 1b261af

Please sign in to comment.