Skip to content

Commit

Permalink
fix: allow non-standard datanames in filter data
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 15, 2024
1 parent aa05f7f commit aef12a6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 50 deletions.
3 changes: 0 additions & 3 deletions R/FilteredData.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@ FilteredData <- R6::R6Class( # nolint
set_dataset = function(data, dataname) {
checkmate::assert_string(dataname)
logger::log_debug("FilteredData$set_dataset setting dataset, name: { dataname }")
# to include it nicely in the Show R Code;
# the UI also uses `datanames` in ids, so no whitespaces allowed
check_simple_name(dataname)

parent_dataname <- teal.data::parent(private$join_keys, dataname)
keys <- private$join_keys[dataname, dataname]
Expand Down
1 change: 0 additions & 1 deletion R/FilteredDataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ FilteredDataset <- R6::R6Class( # nolint
#' @return Object of class `FilteredDataset`, invisibly.
#'
initialize = function(dataset, dataname, keys = character(0), label = attr(dataset, "label", exact = TRUE)) {
check_simple_name(dataname)
logger::log_debug("Instantiating { class(self)[1] }, dataname: { dataname }")
checkmate::assert_character(keys, any.missing = FALSE)
checkmate::assert_character(label, null.ok = TRUE)
Expand Down
25 changes: 0 additions & 25 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
#' Test whether variable name can be used within `Show R Code`
#'
#' Variable names containing spaces are problematic and must be wrapped in backticks.
#' Also, they should not start with a number as `R` may silently make it valid by changing it.
#' Therefore, we only allow alphanumeric characters with underscores.
#' The first character of the `name` must be an alphabetic character and can be followed by alphanumeric characters.
#'
#' @md
#'
#' @param name (`character`) vector of names to check
#' @return Returns `NULL` or raises error.
#' @keywords internal
#'
check_simple_name <- function(name) {
checkmate::assert_character(name, min.len = 1, any.missing = FALSE)
if (!grepl("^[[:alpha:]][a-zA-Z0-9_]*$", name, perl = TRUE)) {
stop(
"name '",
name,
"' must only contain alphanumeric characters (with underscores)",
" and the first character must be an alphabetic character"
)
}
}

#' Include `JS` files from `/inst/js/` package directory to application header
#'
#' `system.file` should not be used to access files in other packages, it does
Expand Down
21 changes: 0 additions & 21 deletions man/check_simple_name.Rd

This file was deleted.

0 comments on commit aef12a6

Please sign in to comment.