Skip to content

Commit cf34644

Browse files
authored
Use a stricter definition of header names (#607)
To make it less likely that URLs (or other non-header contents) are mangled. This only affects verobse printing (including `req_dry_run()`) so it shouldn't cause problems even if it's not 100% accurate. Fixes #567
1 parent b0e2296 commit cf34644

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

R/req-options.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ verbose_header <- function(prefix, x, redact = TRUE, to_redact = NULL) {
207207
lines <- unlist(strsplit(x, "\r?\n", useBytes = TRUE))
208208

209209
for (line in lines) {
210-
if (grepl(":", line, fixed = TRUE)) {
210+
if (grepl("^[-a-zA-z0-9]+:", line)) {
211211
header <- headers_redact(as_headers(line), redact, to_redact = to_redact)
212212
cli::cat_line(prefix, cli::style_bold(names(header)), ": ", header)
213213
} else {

tests/testthat/test-req-perform.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,8 @@ test_that("authorization headers are redacted", {
225225
req_dry_run()
226226
})
227227
})
228+
229+
test_that("doen't add space to urls (#567)", {
230+
req <- request("https://example.com/test:1:2")
231+
expect_output(req_dry_run(req), "test:1:2")
232+
})

0 commit comments

Comments
 (0)