Skip to content

Commit c6eb180

Browse files
committed
Merge pull request #256 from ropensci/fix-3.1.3-error
Sanitize kwargs from class "environment" before posting - Fixes #254
2 parents 5d61202 + 5299d22 commit c6eb180

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

R/plotly.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ plotly_build <- function(l = last_plot()) {
218218
for (i in seq_along(l$data)) {
219219
d <- l$data[[i]]
220220
# if appropriate, evaluate trace arguments in a suitable environment
221-
idx <- names(d) %in% c("args", "env")
222-
if (sum(idx) == 2) {
221+
idx <- names(d) %in% c("args", "env", "enclos")
222+
if (sum(idx) == 3) {
223223
dat <- c(d[!idx], eval(d$args, as.list(d$env), d$enclos))
224224
dat[c("args", "env", "enclos")] <- NULL
225225
# start processing specially named arguments
@@ -275,8 +275,8 @@ plotly_build <- function(l = last_plot()) {
275275
}
276276
for (i in seq_along(l$layout)) {
277277
layout <- l$layout[[i]]
278-
idx <- names(layout) %in% c("args", "env")
279-
x$layout[[i]] <- if (sum(idx) == 2) {
278+
idx <- names(layout) %in% c("args", "env", "enclos")
279+
x$layout[[i]] <- if (sum(idx) == 3) {
280280
c(layout[!idx], eval(layout$args, as.list(layout$env), layout$enclos))
281281
} else {
282282
layout
@@ -287,8 +287,8 @@ plotly_build <- function(l = last_plot()) {
287287
if (!is.null(l$style)) {
288288
for (i in seq_along(l$style)) {
289289
sty <- l$style[[i]]
290-
idx <- names(sty) %in% c("args", "env")
291-
new_sty <- if (sum(idx) == 2) c(sty[!idx], eval(sty$args, as.list(sty$env), sty$enclos)) else sty
290+
idx <- names(sty) %in% c("args", "env", "enclos")
291+
new_sty <- if (sum(idx) == 3) c(sty[!idx], eval(sty$args, as.list(sty$env), sty$enclos)) else sty
292292
for (k in sty$traces) x$data[[k]] <- modifyList(x$data[[k]], new_sty)
293293
}
294294
}

R/plotly_POST.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ plotly_POST <- function(x) {
3131
# empty keyword arguments can cause problems
3232
kwargs <- x[get_kwargs()]
3333
kwargs <- kwargs[sapply(kwargs, length) > 0]
34-
34+
3535
# filename & fileopt are keyword arguments required by the API
3636
# (note they can also be specified by the user)
37-
3837
if (!is.null(x$url) || !is.null(kwargs$filename)) kwargs$fileopt <- "overwrite"
3938
if (is.null(kwargs$filename)) {
4039
kwargs$filename <-

0 commit comments

Comments
 (0)