@@ -1290,6 +1290,10 @@ REV_report_changes <- function(h0, h1, verbose = FALSE) {
12901290
12911291# ' Early error feedback function for the optional review parameter
12921292# '
1293+ # ' @param afmm
1294+ # '
1295+ # ' Pass-through of the server afmm parameter.
1296+ # '
12931297# ' @param datasets `[list(data.frame)]`
12941298# '
12951299# ' Available datasets for review.
@@ -1307,7 +1311,7 @@ REV_report_changes <- function(h0, h1, verbose = FALSE) {
13071311# ' the configuration of the review parameter will be placed here.
13081312# '
13091313# ' @export
1310- check_review_parameter <- function (datasets , dataset_names , review , err ) {
1314+ check_review_parameter <- function (afmm , datasets , dataset_names , review , err ) {
13111315 if (is.null(review )) return (NULL )
13121316 ok <- CM $ assert(
13131317 container = err ,
@@ -1443,4 +1447,48 @@ check_review_parameter <- function(datasets, dataset_names, review, err) {
14431447 )
14441448 }
14451449 }
1450+ if (! ok ) return (NULL )
1451+
1452+ # https://en.wikipedia.org/wiki/Filename#Problematic_characters
1453+ problematic_chars <- c(" /" , " \\\\ " , " ?" , " %" , " *" , " :" , " |" , ' "' , " <" , " >" , " ." , " ," , " ;" , " =" )
1454+ problematic_chars_regexp <- paste(" ([" , paste(problematic_chars , collapse = " " ), " ])" )
1455+
1456+ report_problematic_names <- function (message_template , v ) {
1457+ res <- character (0 )
1458+ for (e in v ){
1459+ matches <- character (0 )
1460+ for (pc in problematic_chars ) if (grepl(pc , e , fixed = TRUE )) {
1461+ single_char <- substr(pc , 1 , 1 ) # deals with backslash
1462+ matches <- c(matches , single_char )
1463+ }
1464+ if (length(matches )) {
1465+ res <- c(res , sprintf(message_template , e , paste(sprintf(" '<b>%s</b>'" , matches ), collapse = " , " )))
1466+ }
1467+ }
1468+ res <- paste(res , collapse = " <br>" )
1469+ return (res )
1470+ }
1471+
1472+ dataset_list_names <- names(afmm [[" data" ]])
1473+ CM $ assert(
1474+ container = err ,
1475+ cond = ! any(grepl(problematic_chars_regexp , dataset_list_names )),
1476+ msg = report_problematic_names(
1477+ paste(' The dataset list name "<b>%s</b>" contains characters (%s) incompatible with the review functionality.' ,
1478+ " That string would be used as part of review-related folder names and those characters could cause problems" ,
1479+ ' <a href="https://en.wikipedia.org/wiki/Filename#Problematic_characters" target="_blank">(details)<a>.' ,
1480+ " Please, exclude them." ),
1481+ dataset_list_names )
1482+ )
1483+ dataset_names <- names(review [[" datasets" ]])
1484+ CM $ assert(
1485+ container = err ,
1486+ cond = ! any(grepl(problematic_chars_regexp , dataset_names )),
1487+ msg = report_problematic_names(
1488+ paste(' The dataset name "<b>%s</b>" contains characters (%s) incompatible with the review functionality.' ,
1489+ " That string would be used as part of review-related file names and those characters could cause problems" ,
1490+ ' <a href="https://en.wikipedia.org/wiki/Filename#Problematic_characters" target="_blank">(details)<a>.' ,
1491+ " Please, exclude them." ),
1492+ dataset_names )
1493+ )
14461494}
0 commit comments