Skip to content

Commit

Permalink
fix Excel attachments (#314) (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
aalucaci authored Nov 11, 2023
1 parent e9bd267 commit 5f60f40
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Suggests:
keyring,
knitr,
spelling,
xml2
xml2,
openxlsx,
withr
SystemRequirements: pandoc (>= 1.12.3) - http://pandoc.org
Encoding: UTF-8
RoxygenNote: 7.2.3
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# blastula (development version)

* Fixed Excel attachments which were broken due to wrong conversion into RFC2822. (#314)

# blastula 0.3.4

* Modified tests to remove specific cases that no longer work in newer versions of R. (#310)
Expand Down
4 changes: 2 additions & 2 deletions R/mime.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ generate_rfc2822 <- function(

quoted_filename <-
header_quoted(
attachment$filename,
str = "Filename",
str = attachment$filename,
fieldname = "Filename",
encode_unicode = TRUE
)

Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-mime.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,27 @@ test_that("varying formats for recipient lists work as expected", {
grepl("(?<!\\r)\n", ., perl = TRUE) %>%
expect_false()
})

test_that("excel attachment", {
email <- compose_email()

withr::with_tempfile(
fileext = ".xlsx",
new = "out_file",
code = {
openxlsx::write.xlsx(x = mtcars, file = out_file)

email <- email %>%
add_attachment(out_file)

generate_rfc2822(
eml = email,
date = Sys.Date(),
subject = NULL,
from = NULL,
to = NULL
) %>%
expect_match(paste0('filename=\"', basename(out_file)))
}
)
})

0 comments on commit 5f60f40

Please sign in to comment.