Skip to content

fix: serialization of \n, \r and \t to Line Protocol, = is valid sign for measurement name #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## 1.10.0 [unreleased]

### Features
1. [#23](https://github.com/influxdata/influxdb-client-csharp/pull/102): Added WriteApiAsync for asynchronous write without batching
1. [#102](https://github.com/influxdata/influxdb-client-csharp/pull/102): Added WriteApiAsync for asynchronous write without batching

### Bug Fixes
1. [#106](https://github.com/influxdata/influxdb-client-csharp/pull/106): Fixed serialization of `\n`, `\r` and `\t` to Line Protocol

## 1.9.0 [2020-06-19]

Expand Down
12 changes: 12 additions & 0 deletions Client.Test/PointDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public void TagEmptyTagValue()
Assert.AreEqual("h2o,location=europe level=2i", point.ToLineProtocol());
}

[Test]
public void TagEscapingKeyAndValue() {

var point = PointData.Measurement("h\n2\ro\t_data")
.Tag("new\nline", "new\nline")
.Tag("carriage\rreturn", "carriage\rreturn")
.Tag("t\tab", "t\tab")
.Field("level", 2);

Assert.AreEqual("h\\n2\\ro\\t_data,carriage\\rreturn=carriage\\rreturn,new\\nline=new\\nline,t\\tab=t\\tab level=2i", point.ToLineProtocol());
}

[Test]
public void Immutability()
{
Expand Down
9 changes: 9 additions & 0 deletions Client/Writes/PointData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ private void EscapeKey(StringBuilder sb, string key)
{
switch (c)
{
case '\n':
sb.Append("\\n");
continue;
case '\r':
sb.Append("\\r");
continue;
case '\t':
sb.Append("\\t");
continue;
case ' ':
case ',':
case '=':
Expand Down