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
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

fix: backslash escaping in serialization to Line protocol#899

Open
sar009 wants to merge3 commits intoinfluxdata:master
base:master
Choose a base branch
Loading
fromsar009:fix/escaping_backslash
Open
Show file tree
Hide file tree
Changes fromall 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
4 changes: 0 additions & 4 deletionsinfluxdb/line_protocol.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,8 +60,6 @@ def _convert_timestamp(timestamp, precision=None):
def _escape_tag(tag):
tag = _get_unicode(tag, force=True)
return tag.replace(
"\\", "\\\\"
).replace(
" ", "\\ "
).replace(
",", "\\,"
Expand All@@ -82,15 +80,13 @@ def _escape_tag_value(value):
def quote_ident(value):
"""Indent the quotes."""
return "\"{}\"".format(value
.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\n", "\\n"))


def quote_literal(value):
"""Quote provided literal."""
return "'{}'".format(value
.replace("\\", "\\\\")
.replace("'", "\\'"))


Expand Down
6 changes: 3 additions & 3 deletionsinfluxdb/tests/test_line_protocol.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,7 @@ def test_make_lines(self):

self.assertEqual(
line_protocol.make_lines(data),
'test,backslash_tag=C:\\\\,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 DownExpand Up@@ -160,14 +160,14 @@ def test_quote_ident(self):
"""Test quote indentation in TestLineProtocol object."""
self.assertEqual(
line_protocol.quote_ident(r"""\foo ' bar " Örf"""),
r'''"\\foo ' bar \" Örf"'''
r'''"\foo ' bar \" Örf"'''
)

def test_quote_literal(self):
"""Test quote literal in TestLineProtocol object."""
self.assertEqual(
line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
r"""'\\foo \' bar " Örf'"""
r"""'\foo \' bar " Örf'"""
)

def test_float_with_long_decimal_fraction(self):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp