Skip to content

Sanitize kwargs from class "environment" before posting - Fixes #254 #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ plotly_build <- function(l = last_plot()) {
for (i in seq_along(l$data)) {
d <- l$data[[i]]
# if appropriate, evaluate trace arguments in a suitable environment
idx <- names(d) %in% c("args", "env")
if (sum(idx) == 2) {
idx <- names(d) %in% c("args", "env", "enclos")
if (sum(idx) == 3) {
dat <- c(d[!idx], eval(d$args, as.list(d$env), d$enclos))
dat[c("args", "env", "enclos")] <- NULL
# start processing specially named arguments
Expand Down Expand Up @@ -275,8 +275,8 @@ plotly_build <- function(l = last_plot()) {
}
for (i in seq_along(l$layout)) {
layout <- l$layout[[i]]
idx <- names(layout) %in% c("args", "env")
x$layout[[i]] <- if (sum(idx) == 2) {
idx <- names(layout) %in% c("args", "env", "enclos")
x$layout[[i]] <- if (sum(idx) == 3) {
c(layout[!idx], eval(layout$args, as.list(layout$env), layout$enclos))
} else {
layout
Expand All @@ -287,8 +287,8 @@ plotly_build <- function(l = last_plot()) {
if (!is.null(l$style)) {
for (i in seq_along(l$style)) {
sty <- l$style[[i]]
idx <- names(sty) %in% c("args", "env")
new_sty <- if (sum(idx) == 2) c(sty[!idx], eval(sty$args, as.list(sty$env), sty$enclos)) else sty
idx <- names(sty) %in% c("args", "env", "enclos")
new_sty <- if (sum(idx) == 3) c(sty[!idx], eval(sty$args, as.list(sty$env), sty$enclos)) else sty
for (k in sty$traces) x$data[[k]] <- modifyList(x$data[[k]], new_sty)
}
}
Expand Down
3 changes: 1 addition & 2 deletions R/plotly_POST.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ plotly_POST <- function(x) {
# empty keyword arguments can cause problems
kwargs <- x[get_kwargs()]
kwargs <- kwargs[sapply(kwargs, length) > 0]

# filename & fileopt are keyword arguments required by the API
# (note they can also be specified by the user)

if (!is.null(x$url) || !is.null(kwargs$filename)) kwargs$fileopt <- "overwrite"
if (is.null(kwargs$filename)) {
kwargs$filename <-
Expand Down