From 76ef423f8c6a68944dc8585c118b812c69c7ded4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:30:11 +0100 Subject: [PATCH] fix: improve on pattern by using ] as first element --- R/utils.R | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/R/utils.R b/R/utils.R index bed69aa6e..9268b448a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -74,14 +74,10 @@ make_c_call <- function(choices) { #' #' @keywords internal sanitize_id <- function(id) { - escape_characters <- " !\"#$%&'()*+,./:;<=>?@[\\]^`{|}~" - pattern <- paste( - sep = "", collapse = "|", "\\", strsplit(escape_characters, "")[[1]] - ) - pattern <- gsub("\\<", "<", pattern, fixed = TRUE) - pattern <- gsub("\\>", ">", pattern, fixed = TRUE) + # Left square bracket needs to be first in the pattern to avoid errors with pattern + pattern_escape <- "[] !\"#$%&'()*+,./:;<=>?@[\\^`{|}~]" - id_new <- gsub(pattern, "_", id) + id_new <- gsub(pattern_escape, "_", id) hashes <- vapply( id[id != id_new], rlang::hash, character(1),