From 38588c6d7588a58d048bcd8136e7c2f1a907f609 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Mon, 21 Oct 2024 18:42:28 +0300 Subject: [PATCH 1/4] Avoid giving arbitrary strings to gettextf err$message is already translated at this point and may contain printf specifiers. Avoid trying to expand it once again. --- R/data.table.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index d0b940ae1..e293e91ee 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -123,7 +123,7 @@ replace_dot_alias = function(e) { stopf("Object '%s' not found amongst %s", used, brackify(ref)) } } else { - stopf(err$message) + stopf("%s", err$message) } } From 5e05b2e7967d86fb12d4cd2abfe91a03af6eae3b Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 21 Oct 2024 09:37:05 -0700 Subject: [PATCH 2/4] Also don't try translating it --- R/data.table.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index e293e91ee..0dd0b7f5f 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -123,7 +123,7 @@ replace_dot_alias = function(e) { stopf("Object '%s' not found amongst %s", used, brackify(ref)) } } else { - stopf("%s", err$message) + stopf("%s", err$message, domain=NA) } } From c9c818a883dcc2a59cdc798b97562684cc6435bc Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 21 Oct 2024 09:38:11 -0700 Subject: [PATCH 3/4] Add a comment --- R/data.table.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/data.table.R b/R/data.table.R index 0dd0b7f5f..1c2c07a3f 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -123,6 +123,7 @@ replace_dot_alias = function(e) { stopf("Object '%s' not found amongst %s", used, brackify(ref)) } } else { + # Don't use stopf() directly, since err$message might have '%', #6588 stopf("%s", err$message, domain=NA) } } From 8c572759ffea46adfcecb067d573b7e2eea820ed Mon Sep 17 00:00:00 2001 From: Ivan K Date: Mon, 21 Oct 2024 23:40:19 +0300 Subject: [PATCH 4/4] Regression test for .checkTypos --- inst/tests/tests.Rraw | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index c530b2fd1..2e90de1ba 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -20591,3 +20591,6 @@ setDT(d2) test(2295.1, !is.data.table(d1)) test(2295.2, rownames(d1), 'b') test(2295.3, is.data.table(d2)) + +# #6588: .checkTypos used to give arbitrary strings to stopf as the first argument +test(2296, d2[x %no such operator% 1], error = '%no such operator%')