Skip to content

Commit edb1063

Browse files
committed
avoid use of as.formula()
it's a security vulnerability
1 parent b6014ac commit edb1063

File tree

1 file changed

+7
-2
lines changed
  • inst/examples/shiny/lmGadget

1 file changed

+7
-2
lines changed

inst/examples/shiny/lmGadget/app.R

+7-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ lm_app <- function(dat, x, y, key = row.names(dat)) {
5151
req(input$degree)
5252
is_outlier <- key %in% keys()
5353
modelDat <- dat[!is_outlier, ]
54-
formula <- as.formula(
55-
sprintf("%s ~ poly(%s, degree = %s)", as.character(y)[2], as.character(x)[2], input$degree)
54+
formula <- substitute(
55+
y ~ poly(x, degree = degree),
56+
list(
57+
y = y[[2]],
58+
x = x[[2]],
59+
degree = input$degree
60+
)
5661
)
5762
m <- lm(formula, modelDat)
5863
modelDat$yhat <- as.numeric(fitted(m))

0 commit comments

Comments
 (0)