Skip to content

Commit 27bc588

Browse files
committed
[annotation] Less intrusive role string sanitization.
1 parent 4d9ab80 commit 27bc588

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

R/mod_listings.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ listings_server <- function(module_id,
389389
"clear_filters",
390390
# NOTE(miguel): Added here for easier merge with other branches
391391
# TODO(miguel): Move elsewhere after merging
392-
REV_UI(ns = ns, roles = review[["roles"]])[["input_ids_to_exclude_from_bookmarking"]]
392+
REV_UI(ns = ns, roles = character(0))[["input_ids_to_exclude_from_bookmarking"]]
393393
))
394394

395395
# Bookmarking (end)
@@ -429,6 +429,10 @@ listings_server <- function(module_id,
429429
} else {
430430
fs_client <- fs_init(fs_callbacks, review[["store_path"]])
431431
}
432+
433+
# Overly restrictive sanitization of role strings, as they will be used for file names:
434+
# TODO: Consider adapting https://github.com/r-lib/fs/blob/main/R/sanitize.R instead to allow alternative charsets
435+
review[["roles"]] <- gsub("[^a-zA-Z0-9 _.-]", "", review[["roles"]]) # Accepts alpha+num+space+'.'+'_'+'-'
432436

433437
output[[TBL$REVIEW_UI_ID]] <- shiny::renderUI(
434438
shinyWidgets::dropdownButton(

R/review.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ REV_include_review_info <- function(annotation_info, data, col_names, extra_col_
6969
}
7070

7171
REV_UI <- function(ns, roles) {
72-
choices <- setNames(c("", roles), c("<select reviewer role>", make.names(roles)))
72+
choices <- setNames(c("", roles), c("<select reviewer role>", roles))
7373

7474
res <- list()
7575
res[["ui"]] <- shiny::tagList(
@@ -108,8 +108,6 @@ REV_load_annotation_info <- function(folder_contents, review, dataset_lists) {
108108
folder_IO_plan <<- c(folder_IO_plan, list(action))
109109
}
110110

111-
review[["roles"]] <- make.names(review[["roles"]])
112-
113111
for (dataset_lists_name in names(dataset_lists)) {
114112
sub_res <- list()
115113
dataset_list <- dataset_lists[[dataset_lists_name]]
@@ -590,7 +588,7 @@ REV_logic_2 <- function(ns, state, input, review, datasets, selected_dataset_lis
590588
SH$double_to_raw(timestamp)
591589
)
592590

593-
fname <- paste0(dataset_name, "_", make.names(role), ".review")
591+
fname <- paste0(dataset_name, "_", role, ".review")
594592

595593
IO_plan <- list(
596594
list(

0 commit comments

Comments
 (0)