Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/pg/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ class Client extends EventEmitter {

// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
escapeIdentifier(str) {
if (str.includes('\0')) {
throw new Error('Identifier contains \\0, which is not allowed in PostgreSQL identifiers')
}
return '"' + str.replace(/"/g, '""') + '"'
}

Expand All @@ -459,6 +462,8 @@ class Client extends EventEmitter {
} else if (c === '\\') {
escaped += c + c
hasBackslash = true
} else if (c === '\0') {
throw new Error('Literal contains \\0, which is not allowed in PostgreSQL strings')
} else {
escaped += c
}
Expand Down