Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 7cb7394e
authored
Feb 08, 2018
by
Christian Holm
Committed by
Jan Aagaard Meier
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(escape): Escape null character in postgres (#9006)
1 parent
f8a98a14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
lib/sql-string.js
test/unit/sql/where.test.js
lib/sql-string.js
View file @
7cb7394
...
...
@@ -55,6 +55,11 @@ function escape(val, timeZone, dialect, format) {
// http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
// http://stackoverflow.com/q/603572/130598
val
=
val
.
replace
(
/'/g
,
"''"
);
if
(
dialect
===
'postgres'
)
{
// null character is not allowed in Postgres
val
=
val
.
replace
(
/
\0
/g
,
'\\0'
);
}
}
else
{
val
=
val
.
replace
(
/
[\0\n\r\b\t\\\'\"\x
1a
]
/g
,
s
=>
{
switch
(
s
)
{
...
...
test/unit/sql/where.test.js
View file @
7cb7394
...
...
@@ -68,6 +68,14 @@ suite(Support.getTestDialectTeaser('SQL'), () => {
default
:
"WHERE [name] = 'a project' AND ([id] IN (1, 2, 3) OR [id] > 10)"
,
mssql
:
"WHERE [name] = N'a project' AND ([id] IN (1, 2, 3) OR [id] > 10)"
});
testsql
({
name
:
'here is a null char: \0'
},
{
default
:
"WHERE [name] = 'here is a null char: \\0'"
,
mssql
:
"WHERE [name] = N'here is a null char: \0'"
,
sqlite
:
"WHERE `name` = 'here is a null char: \0'"
});
});
suite
(
'whereItemQuery'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment