Skip to content

Commit

Permalink
use safe gsub() call
Browse files Browse the repository at this point in the history
- Fix `dbQuoteString()` and `dbQuoteIdentifier()` to ignore invalid UTF-8 strings (r-dbi/DBItest#156).
  • Loading branch information
krlmlr committed Nov 8, 2017
1 parent f8c97f2 commit 716d167
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/quote.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ setMethod("dbQuoteIdentifier", c("DBIConnection", "character"),
if (any(is.na(x))) {
stop("Cannot pass NA to dbQuoteIdentifier()", call. = FALSE)
}
x <- gsub('"', '""', x, fixed = TRUE)
x <- gsub('"', '""', enc2utf8(x), fixed = TRUE, useBytes = TRUE)
if (length(x) == 0L) {
SQL(character())
} else {
Expand Down Expand Up @@ -152,7 +152,7 @@ setGeneric("dbQuoteString",
#' @export
setMethod("dbQuoteString", c("DBIConnection", "character"),
function(conn, x, ...) {
x <- gsub("'", "''", x, fixed = TRUE)
x <- gsub("'", "''", enc2utf8(x), fixed = TRUE, useBytes = TRUE)

if (length(x) == 0L) {
SQL(character())
Expand Down

0 comments on commit 716d167

Please sign in to comment.