Skip to content

Commit 52b393b

Browse files
committed
Decode MIME strings in downloaded file names
1 parent 40be2d3 commit 52b393b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# objr (development version)
22

3+
* Fix bug when downloaded files have MIME encoded-word syntax (#72).
4+
35
# objr 0.2.0
46

57
## New features

R/utils_download-upload.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ file_name_from_header <- function(response,
236236
cont_disp,
237237
m = regexpr("(?<=filename=\\\").*(?=\\\")", cont_disp, perl = TRUE)
238238
) %>%
239+
decode_mime() %>%
239240
utils::URLdecode()
240241

241242
if (length(file_name) == 0) {
@@ -251,3 +252,7 @@ file_name_from_header <- function(response,
251252
file_name
252253

253254
}
255+
256+
decode_mime <- function(string) {
257+
gsub("(^=\\?UTF-8\\?Q\\?)|(\\?=$)", replacement = "", string)
258+
}

0 commit comments

Comments
 (0)