Skip to content
Permalink
Browse files

initial R 3.0.0 compatibility release by dropping `parser` for update…

…d `parse`
  • Loading branch information...
daroczig committed Apr 5, 2013
1 parent b8b4c56 commit 9794327c6c068ceef5c3e79e0b0d3299cad01a23
Showing with 9 additions and 12 deletions.
  1. +2 −2 DESCRIPTION
  2. +0 −1 NAMESPACE
  3. +7 −8 R/sandbox.R
  4. +0 −1 R/sandboxR.R
@@ -12,8 +12,8 @@ Date: 2012-04-02
URL: https://github.com/daroczig/sandboxR
BugReports: https://github.com/daroczig/sandboxR/issues
License: AGPL-3
Imports:
parser
Depends:
R (>= 3.0.0)
Suggests:
pander
Collate:
@@ -2,4 +2,3 @@ export(commands.blacklist)
export(sandbox.env)
export(sandbox.pretest)
export(sandbox)
importFrom(parser,parser)
@@ -40,16 +40,15 @@ sandbox.pretest <- function(src, blacklist = as.character(unlist(commands.blackl
stop('Nothing provided to check.')

## parse elements of src
f <- textConnection(src)
src.r <- suppressWarnings(tryCatch(parser(f), error = function(e) NULL))
close(f)
src.r <- suppressWarnings(tryCatch(parse(text = src), error = function(e) NULL))

if (is.null(nrow(attr(src.r, 'data'))))
stop(paste0('Parsing command (`', src, '`) failed, possible syntax error.'))
p <- attr(src.r, 'data')
calls <- sort(unique(p$text[which(p$token.desc == 'SYMBOL_FUNCTION_CALL')]))
strings <- sort(unique(p$text[which(p$token.desc == 'STR_CONST')]))
vars <- sort(unique(p$text[which(p$token.desc == 'SYMBOL')]))
pkgs <- sort(unique(p$text[which(p$token.desc == 'SYMBOL_PACKAGE')]))
p <- getParseData(src.r)
calls <- sort(unique(p$text[which(p$token == 'SYMBOL_FUNCTION_CALL')]))
strings <- sort(unique(p$text[which(p$token == 'STR_CONST')]))
vars <- sort(unique(p$text[which(p$token == 'SYMBOL')]))
pkgs <- sort(unique(p$text[which(p$token == 'SYMBOL_PACKAGE')]))

## filtering foreign calls
if (length(pkgs) > 0)
@@ -1,7 +1,6 @@
#' \emph{sandboxR}: Filtering "malicious" calls in R
#'
#' @docType package
#' @importFrom parser parser
#' @name sandboxR
NULL

0 comments on commit 9794327

Please sign in to comment.
You can’t perform that action at this time.