Commit ac266677 authored by Tobinsk's avatar Tobinsk
Browse files

Merge branch '2-error-encoding' into 'master'

Escape more params

Closes #2

See merge request !4
parents 23aadf9d 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\x08\x09\x1a\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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment