Skip to content

Commit 76cbcc8

Browse files
committed
fix/cleanup filename
1 parent 86ba0e3 commit 76cbcc8

2 files changed

Lines changed: 16 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased
9+
10+
### Fixed
11+
- When downloading a file with a `'` in the name it would save the file as blob
12+
813
## 1.20.1 - 2022-04-04
914

1015
### Fixed

app/util/FileUtils.scala

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -856,37 +856,20 @@ object FileUtils {
856856
//Download CONTENT-DISPOSITION encoding
857857
//
858858
def encodeAttachment(filename: String, userAgent: String) : String = {
859-
val filenameStar = if (userAgent.indexOf("MSIE") > -1) {
860-
URLEncoder.encode(filename, "UTF-8")
861-
} else if (userAgent.indexOf("Edge") > -1){
862-
MimeUtility.encodeText(filename
863-
.replaceAll(",","%2C")
864-
.replaceAll("\"","%22")
865-
.replaceAll("/","%2F")
866-
.replaceAll("=","%3D")
867-
.replaceAll("&","%26")
868-
.replaceAll(":","%3A")
869-
.replaceAll(";","%3B")
870-
.replaceAll("\\?","%3F")
871-
.replaceAll("\\*","%2A")
859+
val filenameStar = MimeUtility.encodeText(filename
860+
.replaceAll("%","%25")
861+
.replaceAll(" ","%20")
862+
.replaceAll("\"","%22")
863+
.replaceAll("'","%27")
864+
.replaceAll(",","%2C")
865+
.replaceAll("/","%2F")
866+
.replaceAll("=","%3D")
867+
.replaceAll(":","%3A")
868+
.replaceAll(";","%3B")
869+
.replaceAll("\\*","%2A")
872870
,"utf-8","Q")
873-
} else {
874-
MimeUtility.encodeText(filename
875-
.replaceAll("%","%25")
876-
.replaceAll(" ","%20")
877-
.replaceAll("\"","%22")
878-
.replaceAll(",","%2C")
879-
.replaceAll("/","%2F")
880-
.replaceAll("=","%3D")
881-
.replaceAll(":","%3A")
882-
.replaceAll(";","%3B")
883-
.replaceAll("\\*","%2A")
884-
,"utf-8","Q")
885-
}
886-
Logger.debug(userAgent + ": " + filenameStar)
887871

888872
//Return the complete attachment header info
889873
"attachment; filename*=UTF-8''" + filenameStar
890874
}
891-
892875
}

0 commit comments

Comments
 (0)