Skip to content

Commit

Permalink
#302 Encode filename when downloading attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Sep 5, 2017
1 parent bf1c866 commit dbaff4e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions thehive-backend/app/controllers/AttachmentCtrl.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package controllers

import java.net.URLEncoder
import java.nio.file.Files
import javax.inject.{ Inject, Singleton }

Expand Down Expand Up @@ -62,7 +63,7 @@ class AttachmentCtrl(
header = ResponseHeader(
200,
Map(
"Content-Disposition" s"""attachment; filename="${name.getOrElse(hash)}"""",
"Content-Disposition" s"""attachment; filename="${URLEncoder.encode(name.getOrElse(hash), "utf-8")}"""",
"Content-Transfer-Encoding" "binary")),
body = HttpEntity.Streamed(attachmentSrv.source(hash), None, None))
}
Expand Down Expand Up @@ -93,7 +94,7 @@ class AttachmentCtrl(
header = ResponseHeader(
200,
Map(
"Content-Disposition" s"""attachment; filename="${name.getOrElse(hash)}.zip"""",
"Content-Disposition" s"""attachment; filename="${URLEncoder.encode(name.getOrElse(hash), "utf-8")}.zip"""",
"Content-Type" "application/zip",
"Content-Transfer-Encoding" "binary",
"Content-Length" Files.size(f).toString)),
Expand Down

0 comments on commit dbaff4e

Please sign in to comment.