From 9d08696f6f39032daa5b8103f73ab111a3851622 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 29 Dec 2025 13:36:14 -0800 Subject: [PATCH 1/5] skip file:// when checking if the file exists --- R/fread.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/fread.R b/R/fread.R index 16a72ed24..87a544ad7 100644 --- a/R/fread.R +++ b/R/fread.R @@ -63,7 +63,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC") # input is data itself containing at least one \n or \r } else if (startsWith(input, " ")) { stopf("input= contains no \\n or \\r, but starts with a space. Please remove the leading space, or use text=, file= or cmd=") - } else if (length(grep(' ', input, fixed=TRUE)) && !file.exists(input)) { # file name or path containing spaces is not a command + } else if (length(grep(' ', input, fixed=TRUE)) && !file.exists(gsub("^file://", "", input))) { # file name or path containing spaces is not a command. file.exists() doesn't understand file:// (#7550) cmd = input if (input_has_vars && getOption("datatable.fread.input.cmd.message", TRUE)) { messagef("Taking input= as a system command because it contains a space ('%s'). If it's a filename please remove the space, or use file= explicitly. A variable is being passed to input= and when this is taken as a system command there is a security concern if you are creating an app, the app could have a malicious user, and the app is not running in a secure environment; e.g. the app is running as root. Please read item 5 in the NEWS file for v1.11.6 for more information and for the option to suppress this message.", cmd) From 9e5c382821d8a860ee840a5a97598479c2a7492e Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 29 Dec 2025 13:43:13 -0800 Subject: [PATCH 2/5] regression test --- inst/tests/tests.Rraw | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index c7205e52a..b8ebc0ddb 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21959,3 +21959,13 @@ test(2355.1, fread(txt, skip=0), data.table(V1 = c("b1", "c1"), a1 test(2355.2, fread(txt, skip=0, header=TRUE), data.table(V1 = c("b1", "c1"), a1 = c("b2", "c2"), a2 = c("b3", "c3")), warning="Added an extra default column name") test(2355.3, fread(txt, skip=0, header=FALSE), data.table(V1=character(), V2=character(), V3=character()), warning="Consider fill=TRUE") test(2355.4, fread(txt, skip=0, fill=TRUE), data.table(V1 = c("a1", "b1", "c1"), V2 = c("a2", "b2", "c2"), V3 = c("", "b3", "c3"))) + +# fread works on file:// URIs with spaces, #7550 +local({ + f = tempfile("with spaces"); on.exit(unlink(f)) + DT = data.table(a = 1, b = 2) + fwrite(DT, f) + + test(2355.1, fread(f), DT) + test(2355.2, fread(paste0("file://", f)), DT) +}) From 27e32dc1742f1918675c4aba551aeece83b1e157 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 29 Dec 2025 13:50:30 -0800 Subject: [PATCH 3/5] storage type match on round trip --- inst/tests/tests.Rraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index b8ebc0ddb..2c348e7ed 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21963,7 +21963,7 @@ test(2355.4, fread(txt, skip=0, fill=TRUE), data.table(V1 = c("a1", "b1", "c1"), # fread works on file:// URIs with spaces, #7550 local({ f = tempfile("with spaces"); on.exit(unlink(f)) - DT = data.table(a = 1, b = 2) + DT = data.table(a = 1L, b = 2L) fwrite(DT, f) test(2355.1, fread(f), DT) From f409f71fe9786076366dbe1a009ba7f5d5a062c2 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 29 Dec 2025 13:52:08 -0800 Subject: [PATCH 4/5] NEWS entry --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 1a6ca751d..97d31870d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -28,6 +28,8 @@ 1. `fread()` with `skip=0` and `(header=TRUE|FALSE)` no longer skips the first row when it has fewer fields than subsequent rows, [#7463](https://github.com/Rdatatable/data.table/issues/7463). Thanks @emayerhofer for the report and @ben-schwen for the fix. +2. `fread("file://...")` works for file URIs with spaces, [#7550](https://github.com/Rdatatable/data.table/issues/7550). Thanks @aitap for the report and @MichaelChirico for the PR. + ## data.table [v1.18.0](https://github.com/Rdatatable/data.table/milestone/37?closed=1) 23 December 2025 ### BREAKING CHANGE From f2beb63af5bb21ca0aa98fbe4d6c9e1b9e244e3f Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 29 Dec 2025 14:11:43 -0800 Subject: [PATCH 5/5] test number --- inst/tests/tests.Rraw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 2c348e7ed..3861d7732 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21966,6 +21966,6 @@ local({ DT = data.table(a = 1L, b = 2L) fwrite(DT, f) - test(2355.1, fread(f), DT) - test(2355.2, fread(paste0("file://", f)), DT) + test(2356.1, fread(f), DT) + test(2356.2, fread(paste0("file://", f)), DT) })