Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Webui: dvrfile - fix the attachment filename cutoff, fixes #3136
  • Loading branch information
perexg committed Oct 12, 2015
1 parent 85e4f7a commit 67b71ee
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/webui/webui.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 67b71ee

Please sign in to comment.