From: Jaroslav Kysela Date: Mon, 12 Oct 2015 10:12:32 +0000 (+0200) Subject: Webui: dvrfile - fix the attachment filename cutoff, fixes #3136 X-Git-Tag: v4.2.1~1939 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67b71ee8adfb996038b2fceeb3d7b8b66250c559;p=thirdparty%2Ftvheadend.git Webui: dvrfile - fix the attachment filename cutoff, fixes #3136 --- diff --git a/src/webui/webui.c b/src/webui/webui.c index 11558f6fd..4180c95c9 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -1468,7 +1468,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) char *basename; char *str, *str0; char range_buf[255]; - char disposition[512]; + char *disposition = NULL; off_t content_len, chunk; intmax_t file_start, file_end; void *tcp_id; @@ -1501,7 +1501,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) } if(dvr_entry_verify(de, hc->hc_access, 1)) { pthread_mutex_unlock(&global_lock); - return HTTP_STATUS_NOT_FOUND; + return HTTP_STATUS_UNAUTHORIZED; } fname = tvh_strdupa(filename); @@ -1517,14 +1517,14 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) htsbuf_queue_init(&q, 0); htsbuf_append_and_escape_url(&q, basename); str = htsbuf_to_string(&q); - snprintf(disposition, sizeof(disposition), + r = 50 + strlen(str0) + strlen(str); + disposition = alloca(r); + snprintf(disposition, r, "attachment; filename=\"%s\"; filename*=UTF-8''%s", str0, str); htsbuf_queue_flush(&q); free(str); free(str0); - } else { - disposition[0] = 0; } fd = tvh_open(fname, O_RDONLY, 0); @@ -1595,8 +1595,7 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) http_send_header(hc, range ? HTTP_STATUS_PARTIAL_CONTENT : HTTP_STATUS_OK, content, content_len, NULL, NULL, 10, - range ? range_buf : NULL, - disposition[0] ? disposition : NULL, NULL); + range ? range_buf : NULL, disposition, NULL); ret = 0; if(!hc->hc_no_output) {