Skip to content

Commit

Permalink
Merge pull request #1434 from haiwen/file-access-header
Browse files Browse the repository at this point in the history
[access file] add nosniff X-Content-Type-Options header
  • Loading branch information
killing committed Nov 9, 2015
2 parents c4a6fff + a032c0e commit b9fe131
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/access-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ extern SeafileSession *seaf;

static struct file_type_map ftmap[] = {
{ "txt", "text/plain" },
{ "html", "text/html" },
{ "doc", "application/vnd.ms-word" },
{ "docx", "application/vnd.ms-word" },
{ "ppt", "application/vnd.ms-powerpoint" },
Expand Down Expand Up @@ -594,6 +593,10 @@ do_file(evhtp_request_t *req, SeafRepo *repo, const char *file_id,
evhtp_header_new("Content-Disposition", cont_filename,
1, 1));

evhtp_headers_add_header(req->headers_out,
evhtp_header_new("X-Content-Type-Options", "nosniff",
1, 1));

/* If it's an empty file, send an empty reply. */
if (file->n_blocks == 0) {
evhtp_send_reply (req, EVHTP_RES_OK);
Expand Down Expand Up @@ -936,6 +939,9 @@ do_file_range (evhtp_request_t *req, SeafRepo *repo, const char *file_id,

set_resp_disposition (req, operation, filename);

evhtp_headers_add_header(req->headers_out,
evhtp_header_new("X-Content-Type-Options", "nosniff",
1, 1));
data = g_new0 (SendFileRangeData, 1);
if (!data) {
seafile_unref (file);
Expand Down

0 comments on commit b9fe131

Please sign in to comment.