File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -444,7 +444,10 @@ class Client extends EventEmitter {
444
444
445
445
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
446
446
escapeIdentifier ( str ) {
447
- return '"' + str . replace ( / [ " \0 ] / g, '""' ) + '"'
447
+ if ( / \0 / . test ( str ) ) {
448
+ throw new Error ( "Identifier contains \\0 which is not allowed in PostgreSQL identifiers." )
449
+ }
450
+ return '"' + str . replace ( / " / g, '""' ) + '"'
448
451
}
449
452
450
453
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
@@ -460,7 +463,7 @@ class Client extends EventEmitter {
460
463
escaped += c + c
461
464
hasBackslash = true
462
465
} else if ( c === '\0' ) {
463
- // Ignore it
466
+ throw new Error ( "Literal contains \\0 which is not allowed in PostgreSQL strings." ) ;
464
467
} else {
465
468
escaped += c
466
469
}
You can’t perform that action at this time.
0 commit comments