Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Escape tag values that ends with backslash #537

Merged
merged 4 commits into from
Dec 11, 2017
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
9 changes: 8 additions & 1 deletion influxdb/line_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def _escape_tag(tag):
)


def _escape_tag_value(value):
ret = _escape_tag(value)
if ret.endswith('\\'):
ret += ' '
return ret


def quote_ident(value):
"""Indent the quotes."""
return "\"{}\"".format(value
Expand Down Expand Up @@ -135,7 +142,7 @@ def make_lines(data, precision=None):
# tags should be sorted client-side to take load off server
for tag_key, tag_value in sorted(iteritems(tags)):
key = _escape_tag(tag_key)
value = _escape_tag(tag_value)
value = _escape_tag_value(tag_value)

if key != '' and value != '':
key_values.append(key + "=" + value)
Expand Down
3 changes: 2 additions & 1 deletion influxdb/tests/test_line_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_make_lines(self):
"tags": {
"empty_tag": "",
"none_tag": None,
"backslash_tag": "C:\\",
"integer_tag": 2,
"string_tag": "hello"
},
Expand All @@ -41,7 +42,7 @@ def test_make_lines(self):

self.assertEqual(
line_protocol.make_lines(data),
'test,integer_tag=2,string_tag=hello '
'test,backslash_tag=C:\\\\ ,integer_tag=2,string_tag=hello '
'bool_val=True,float_val=1.1,int_val=1i,string_val="hello!"\n'
)

Expand Down
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