Skip to content

Commit

Permalink
initial R 3.0.0 compatibility release by dropping parser for update…
Browse files Browse the repository at this point in the history
…d `parse`
  • Loading branch information
daroczig committed Apr 5, 2013
1 parent b8b4c56 commit 9794327
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Date: 2012-04-02
URL: https://github.com/daroczig/sandboxR URL: https://github.com/daroczig/sandboxR
BugReports: https://github.com/daroczig/sandboxR/issues BugReports: https://github.com/daroczig/sandboxR/issues
License: AGPL-3 License: AGPL-3
Imports: Depends:
parser R (>= 3.0.0)
Suggests: Suggests:
pander pander
Collate: Collate:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export(commands.blacklist)
export(sandbox.env) export(sandbox.env)
export(sandbox.pretest) export(sandbox.pretest)
export(sandbox) export(sandbox)
importFrom(parser,parser)
15 changes: 7 additions & 8 deletions R/sandbox.R
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ sandbox.pretest <- function(src, blacklist = as.character(unlist(commands.blackl
stop('Nothing provided to check.') stop('Nothing provided to check.')


## parse elements of src ## parse elements of src
f <- textConnection(src) src.r <- suppressWarnings(tryCatch(parse(text = src), error = function(e) NULL))
src.r <- suppressWarnings(tryCatch(parser(f), error = function(e) NULL))
close(f)
if (is.null(nrow(attr(src.r, 'data')))) if (is.null(nrow(attr(src.r, 'data'))))
stop(paste0('Parsing command (`', src, '`) failed, possible syntax error.')) stop(paste0('Parsing command (`', src, '`) failed, possible syntax error.'))
p <- attr(src.r, 'data') p <- getParseData(src.r)
calls <- sort(unique(p$text[which(p$token.desc == 'SYMBOL_FUNCTION_CALL')])) calls <- sort(unique(p$text[which(p$token == 'SYMBOL_FUNCTION_CALL')]))
strings <- sort(unique(p$text[which(p$token.desc == 'STR_CONST')])) strings <- sort(unique(p$text[which(p$token == 'STR_CONST')]))
vars <- sort(unique(p$text[which(p$token.desc == 'SYMBOL')])) vars <- sort(unique(p$text[which(p$token == 'SYMBOL')]))
pkgs <- sort(unique(p$text[which(p$token.desc == 'SYMBOL_PACKAGE')])) pkgs <- sort(unique(p$text[which(p$token == 'SYMBOL_PACKAGE')]))


## filtering foreign calls ## filtering foreign calls
if (length(pkgs) > 0) if (length(pkgs) > 0)
Expand Down
1 change: 0 additions & 1 deletion R/sandboxR.R
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
#' \emph{sandboxR}: Filtering "malicious" calls in R #' \emph{sandboxR}: Filtering "malicious" calls in R
#' #'
#' @docType package #' @docType package
#' @importFrom parser parser
#' @name sandboxR #' @name sandboxR
NULL NULL


0 comments on commit 9794327

Please sign in to comment.