Skip to content

Commit e5b845e

Browse files
.checkTypos: Avoid giving arbitrary strings to gettextf (#6590)
* 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. * Also don't try translating it * Add a comment * Regression test for .checkTypos --------- Co-authored-by: Michael Chirico <[email protected]>
1 parent 717981d commit e5b845e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

R/data.table.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ replace_dot_alias = function(e) {
123123
stopf("Object '%s' not found amongst %s", used, brackify(ref))
124124
}
125125
} else {
126-
stopf(err$message)
126+
# Don't use stopf() directly, since err$message might have '%', #6588
127+
stopf("%s", err$message, domain=NA)
127128
}
128129
}
129130

inst/tests/tests.Rraw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20591,3 +20591,6 @@ setDT(d2)
2059120591
test(2295.1, !is.data.table(d1))
2059220592
test(2295.2, rownames(d1), 'b')
2059320593
test(2295.3, is.data.table(d2))
20594+
20595+
# #6588: .checkTypos used to give arbitrary strings to stopf as the first argument
20596+
test(2296, d2[x %no such operator% 1], error = '%no such operator%')

0 commit comments

Comments
 (0)