Skip to content

Fix double quote guard #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redisgraph.js",
"version": "2.2.0",
"version": "2.2.1",
"description": "Connect to RedisGraph 1.0.0 and up from JavaScript",
"author": "RedisLabs",
"license": "BSD 3",
Expand Down
4 changes: 2 additions & 2 deletions src/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class Graph {
let paramType = typeof paramValue;
if (paramType == "string") {
let strValue = "";
paramValue = paramValue.replace(/[\\"']/g, '\\$&');
paramValue = paramValue.replace(/[\\"']/g, '\\$&');
if (paramValue[0] != '"') strValue += '"';
strValue += paramValue;
if (paramValue[paramValue.length - 1] != '"') strValue += '"';
if (!paramValue.endsWith('"') || paramValue.endsWith("\\\"")) strValue += '"';
return strValue;
}
if (Array.isArray(paramValue)) {
Expand Down
7 changes: 5 additions & 2 deletions test/redisGraphAPITest.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,14 @@ describe("RedisGraphAPI Test", () => {
[1, 2, 3],
["1", "2", "3"],
null,
'test"abc'
'test"abc',
"test\"abc2",
"\"testabc3",
"testabc4\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean?

             "testabc4\\"" 

];
let promises = [];
for (var i = 0; i < params.length; i++) {
let param = { param: params[i] };
let param = { param: params[i] };
promises.push(api.query("RETURN $param", param));
}
let values = await Promise.all(promises);
Expand Down