From 051da0c9d3d5657a98e124efcafbceb19b310318 Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Mon, 30 Oct 2017 12:11:18 +0200 Subject: [PATCH 1/3] FAM-1163 escape tag values that ends with backslash --- influxdb/line_protocol.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index c399a1d5..e8816fc0 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -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 @@ -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) From 4585a13b6ca103b79965d70a50af9ab84c11b8db Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Mon, 20 Nov 2017 17:11:13 +0200 Subject: [PATCH 2/3] Add tests for _escape_tag_value func --- influxdb/tests/test_line_protocol.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index dbee8cda..44b46bc3 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -22,6 +22,7 @@ def test_make_lines(self): "tags": { "empty_tag": "", "none_tag": None, + "backslash_tag": "C:\\", "integer_tag": 2, "string_tag": "hello" }, @@ -39,9 +40,10 @@ def test_make_lines(self): ] } + print(line_protocol.make_lines(data)) 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' ) From 56432bc3a42c7d7d304cb9fcfd8d616d1a836124 Mon Sep 17 00:00:00 2001 From: Ivan Kovalkovskyi Date: Tue, 21 Nov 2017 11:56:12 +0200 Subject: [PATCH 3/3] Remove print statement --- influxdb/tests/test_line_protocol.py | 1 - 1 file changed, 1 deletion(-) diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index 44b46bc3..a3d84793 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -40,7 +40,6 @@ def test_make_lines(self): ] } - print(line_protocol.make_lines(data)) self.assertEqual( line_protocol.make_lines(data), 'test,backslash_tag=C:\\\\ ,integer_tag=2,string_tag=hello ' 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