shinyvalidate
shinyvalidate copied to clipboard
PCRE pattern compilation error with sv_url
I'm getting an error in some environments with the sv_url
function. Is it possible there is an unstated system requirement? I am unsure where the error may be coming from otherwise.
PCRE pattern compilation error
'invalid UTF-8 string'
> example("sv_url")
sv_url> ## Only run examples in interactive R sessions
sv_url> if (interactive()) {
sv_url+
sv_url+ library(shiny)
sv_url+ library(shinyvalidate)
sv_url+
sv_url+ ui <- fluidPage(
sv_url+ textInput("url", "URL")
sv_url+ )
sv_url+
sv_url+ server <- function(input, output, session) {
sv_url+
sv_url+ # Validation rules are set in the server, start by
sv_url+ # making a new instance of an `InputValidator()`
sv_url+ iv <- InputValidator$new()
sv_url+
sv_url+ # Basic usage: `sv_url()` works well with its
sv_url+ # defaults; a message will be displayed if the
sv_url+ # validation of `input$address` fails
sv_url+ iv$add_rule("url", sv_url())
sv_url+
sv_url+ # Finally, `enable()` the validation rules
sv_url+ iv$enable()
sv_url+ }
sv_url+
sv_url+ shinyApp(ui, server)
sv_url+
sv_url+ }
Listening on http://127.0.0.1:6179
Warning in grepl("^(?:(?:http(?:s)?|ftp)://)(?:\\S+(?::(?:\\S)*)?@)?(?:(?:[a-z0-9¡-\uffff](?:-)*)*(?:[a-z0-9¡-\uffff])+)(?:\\.(?:[a-z0-9¡-\uffff](?:-)*)*(?:[a-z0-9¡-\uffff])+)*(?:\\.(?:[a-z0-9¡-\uffff]){2,})(?::(?:\\d){2,5})?(?:/(?:\\S)*)?$", :
PCRE pattern compilation error
'invalid UTF-8 string'
at '](?:-)*)*(?:[a-z0-9¡-])+)(?:\.(?:[a-z0-9¡-](?:-)*)*(?:[a-z0-9¡-])+)*(?:\.(?:[a-z0-9¡-]){2,})(?::(?:\d){2,5})?(?:/(?:\S)*)?$'
Warning: Error in grepl: invalid regular expression '^(?:(?:http(?:s)?|ftp)://)(?:\S+(?::(?:\S)*)?@)?(?:(?:[a-z0-9¡-](?:-)*)*(?:[a-z0-9¡-])+)(?:\.(?:[a-z0-9¡-](?:-)*)*(?:[a-z0-9¡-])+)*(?:\.(?:[a-z0-9¡-]){2,})(?::(?:\d){2,5})?(?:/(?:\S)*)?$'
71: grepl
70: rule_fn
69: <Anonymous>
67: rule$rule
53: <Anonymous>
52: mapply
51: self$`_validate_impl`
50: self$validate
49: ::
shiny
observe
48: <observer>
5: runApp
4: print.shiny.appobj
2: source
1: example
Here is the session info:
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyvalidate_0.1.2 shiny_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.8 crayon_1.5.0 digest_0.6.29 later_1.3.0 mime_0.12
[6] R6_2.5.1 jsonlite_1.8.0 lifecycle_1.0.1 xtable_1.8-4 magrittr_2.0.2
[11] cachem_1.0.6 rlang_1.0.4 cli_3.3.0 rstudioapi_0.13 promises_1.2.0.1
[16] jquerylib_0.1.4 bslib_0.3.1 ellipsis_0.3.2 tools_3.6.0 rsconnect_0.8.26
[21] httpuv_1.6.5 fastmap_1.1.0 compiler_3.6.0 htmltools_0.5.2 sass_0.4.0
Note that I have run this successfully in R 3.6.0 on my Mac, so I don't think it is as simple as an R version thing. Please let me know if you have any suggestions. Thanks.
This note on the man page for grepl
seems relevant:
Caseless matching with ‘perl = TRUE’ for non-ASCII characters depends on the PCRE library being compiled with ‘Unicode property support’: an external library might not be.
As do these configuration checks:
> extSoftVersion()
zlib bzlib
"1.2.7" "1.0.6, 6-Sept-2010"
xz PCRE
"5.2.2" "8.32 2012-11-30"
ICU TRE
"50.2" "TRE 0.8.0 (BSD)"
iconv readline
"glibc 2.17" "6.2"
BLAS
"/usr/lib64/R/lib/libRblas.so"
> pcre_config()
UTF-8 Unicode properties JIT stack
TRUE TRUE TRUE TRUE
I think the relevant piece here is that if R is linked with an older PCRE(1) such as the 8.32 on this instance, sv_url
isn't going to work.