Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
histhub
linker
Commits
17b1fad8
Commit
17b1fad8
authored
Jun 13, 2019
by
Tobias Steiner
Browse files
Escape more params
parent
ca1d086b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/neo4j-stream-writer.ts
View file @
17b1fad8
...
...
@@ -11,43 +11,22 @@ import {Writable} from 'stream';
import
Session
from
'
neo4j-driver/types/v1/session
'
;
import
Driver
from
'
neo4j-driver/types/v1/driver
'
;
import
{
InterfaceCore
}
from
'
geolinker-common/dist/core
'
;
import
*
as
jsesc
from
'
jsesc
'
;
class
Neo4jStreamWriter
extends
Writable
{
private
neo4j
;
private
timeout
=
500
;
private
core
;
/**
* Escape special characters
* @param {string} param
* @returns {string}
*/
private
static
escape
(
param
:
string
)
{
// from https://github.com/packagestats/sql-escape/blob/master/index.js
return
param
.
replace
(
/
[\0\x
08
\x
09
\x
1a
\n\r
"'
\\\%]
/g
,
(
char
)
=>
{
switch
(
char
)
{
case
'
\
0
'
:
return
'
\\
0
'
;
case
'
\
x08
'
:
return
'
\\
b
'
;
case
'
\
x09
'
:
return
'
\\
t
'
;
case
'
\
x1a
'
:
return
'
\\
z
'
;
case
'
\n
'
:
return
'
\\
n
'
;
case
'
\r
'
:
return
'
\\
r
'
;
case
'
\
"
'
:
case
'
\'
'
:
case
'
\\
'
:
case
'
%
'
:
// prepends a backslash to backslash, percent, and double/single quotes
return
'
\\
'
+
char
;
}
});
return
jsesc
(
param
);
}
private
neo4j
;
private
timeout
=
500
;
private
core
;
constructor
(
options
=
{},
neo4j
:
Driver
,
core
:
InterfaceCore
)
{
super
(
options
);
this
.
neo4j
=
neo4j
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment