Skip to content

Commit

Permalink
.checkTypos: Avoid giving arbitrary strings to gettextf (#6590)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
aitap and MichaelChirico authored Oct 21, 2024
1 parent 717981d commit e5b845e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ replace_dot_alias = function(e) {
stopf("Object '%s' not found amongst %s", used, brackify(ref))
}
} else {
stopf(err$message)
# Don't use stopf() directly, since err$message might have '%', #6588
stopf("%s", err$message, domain=NA)
}
}

Expand Down
3 changes: 3 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -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%')

0 comments on commit e5b845e

Please sign in to comment.