PLT-7740 Update encoding of filename in file headers (#7552)

* Remove URL escaping of filename in file headers

* Add encoding for filename
This commit is contained in:
Joram Wilander
2017-10-19 15:01:45 -04:00
committed by GitHub
parent e60f97b4a8
commit cbb18479e9

View File

@@ -337,10 +337,12 @@ func writeFileResponse(filename string, contentType string, bytes []byte, forceD
toDownload = !isMediaType
}
filename = url.PathEscape(filename)
if toDownload {
w.Header().Set("Content-Disposition", "attachment;filename=\""+filename+"\"; filename*=UTF-8''"+url.QueryEscape(filename))
w.Header().Set("Content-Disposition", "attachment;filename=\""+filename+"\"; filename*=UTF-8''"+filename)
} else {
w.Header().Set("Content-Disposition", "inline;filename=\""+filename+"\"; filename*=UTF-8''"+url.QueryEscape(filename))
w.Header().Set("Content-Disposition", "inline;filename=\""+filename+"\"; filename*=UTF-8''"+filename)
}
// prevent file links from being embedded in iframes