Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a825bc

Browse files
authored
String cleanse (#2548)
* Fixed string escape and added tests* Add Change* Name change
1 parentf46d7f3 commit4a825bc

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

‎CHANGES‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fix string cleanse in Redis Graph
12
* Make PythonParser resumable in case of error (#2510)
23
* Add `timeout=None` in `SentinelConnectionManager.read_response`
34
* Documentation fix: password protected socket connection (#2374)

‎redis/commands/helpers.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def quote_string(v):
115115
iflen(v)==0:
116116
return'""'
117117

118+
v=v.replace("\\","\\\\")
118119
v=v.replace('"','\\"')
119120

120121
returnf'"{v}"'

‎tests/test_graph.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_path(client):
124124

125125
@pytest.mark.redismod
126126
deftest_param(client):
127-
params= [1,2.3,"str",True,False,None, [0,1,2]]
127+
params= [1,2.3,"str",True,False,None, [0,1,2],r"\" RETURN 1337 //"]
128128
query="RETURN $param"
129129
forparaminparams:
130130
result=client.graph().query(query, {"param":param})

‎tests/test_helpers.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,9 @@ def test_quote_string():
8080
assertquote_string("hello world!")=='"hello world!"'
8181
assertquote_string("")=='""'
8282
assertquote_string("hello world!")=='"hello world!"'
83+
assertquote_string("abc")=='"abc"'
84+
assertquote_string("")=='""'
85+
assertquote_string('"')==r'"\""'
86+
assertquote_string(r"foo \ bar")==r'"foo \\ bar"'
87+
assertquote_string(r"foo \" bar")==r'"foo \\\" bar"'
88+
assertquote_string('a"a')==r'"a\"a"'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp