Skip to content

Commit 53e0c41

Browse files
committed
No port numbers in netrc files
They are not allowed, so compare host names only, without port numbers. For r-lib/pak#749
1 parent f3476f6 commit 53e0c41

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

R/auth.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ repo_auth_netrc <- function(host, username) {
337337
}
338338
if (!file.exists(netrc_path)) return(NULL)
339339

340+
# netrc files do not allow port numbers
341+
host <- sub(":[0-9]+$", "", host)
342+
340343
lines <- readLines(netrc_path, warn = FALSE)
341344
# mark potential end of macros with NA
342345
lines[lines == ""] <- NA_character_

tests/testthat/test-auth.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ test_that("http requests with auth from netrc", {
311311
url2 <- set_user_in_url(url)
312312
authurls <- parse_url_basic_auth(url2)
313313
writeLines(c(
314-
paste0("machine ", authurls$host),
314+
paste0("machine ", sub(":[0-9]+$", "", authurls$host)),
315315
"login username",
316316
"password token"
317317
), netrc)

0 commit comments

Comments
 (0)