Skip to content

Commit 6b5db78

Browse files
vaniakovxginn8
authored andcommitted
Escape tag values that ends with backslash (influxdata#537)
* FAM-1163 escape tag values that ends with backslash * Add tests for _escape_tag_value func * Remove print statement
1 parent df70f5c commit 6b5db78

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

influxdb/line_protocol.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def _escape_tag(tag):
5757
)
5858

5959

60+
def _escape_tag_value(value):
61+
ret = _escape_tag(value)
62+
if ret.endswith('\\'):
63+
ret += ' '
64+
return ret
65+
66+
6067
def quote_ident(value):
6168
"""Indent the quotes."""
6269
return "\"{}\"".format(value
@@ -135,7 +142,7 @@ def make_lines(data, precision=None):
135142
# tags should be sorted client-side to take load off server
136143
for tag_key, tag_value in sorted(iteritems(tags)):
137144
key = _escape_tag(tag_key)
138-
value = _escape_tag(tag_value)
145+
value = _escape_tag_value(tag_value)
139146

140147
if key != '' and value != '':
141148
key_values.append(key + "=" + value)

influxdb/tests/test_line_protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_make_lines(self):
2222
"tags": {
2323
"empty_tag": "",
2424
"none_tag": None,
25+
"backslash_tag": "C:\\",
2526
"integer_tag": 2,
2627
"string_tag": "hello"
2728
},
@@ -41,7 +42,7 @@ def test_make_lines(self):
4142

4243
self.assertEqual(
4344
line_protocol.make_lines(data),
44-
'test,integer_tag=2,string_tag=hello '
45+
'test,backslash_tag=C:\\\\ ,integer_tag=2,string_tag=hello '
4546
'bool_val=True,float_val=1.1,int_val=1i,string_val="hello!"\n'
4647
)
4748

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy