Skip to content

Commit

Permalink
Merge pull request #348 from jmbarbone/347-sanitize-token
Browse files Browse the repository at this point in the history
resolves #347 - lowercase characters in token
  • Loading branch information
wibeasley authored Jul 22, 2021
2 parents 9f6b4ae + 8caa842 commit 90e52f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Upcoming Versions
==========================================================

In the future:
...
### Minor Enhacements

* `sanitize_token()` no longer fails with lowercase characters (#347)

Version 1.0 (released 2021-07-21)
==========================================================
Expand Down
2 changes: 1 addition & 1 deletion R/sanitize-token.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#' @export
sanitize_token <- function(token) {
pattern <- "^([0-9A-F]{32})(?:\\n)?$"
pattern <- "^([0-9A-Fa-f]{32})(?:\\n)?$"

if (is.na(token)) {
stop(
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-sanitize.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ test_that("sanitize token -empty", {
regexp = "The token is an empty string, not a valid 32-character hexademical value\\."
)
})

test_that("sanitize token - lowercase (#347)", {
secret_token <- "12345678901234567890123456abcdef"
sanitize_token(secret_token)

returned <- REDCapR::sanitize_token(secret_token)
# No change
expect_equal(returned, secret_token)
})

0 comments on commit 90e52f7

Please sign in to comment.