From 19cc07bc83c4a61c8cde1d383d80c3f9ef863ef1 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 27 Mar 2026 16:58:08 +0100 Subject: [PATCH 1/3] fix: remove unnecessary escapes in tag tests and update parser --- .../client/internal/InfluxQLQueryApiImpl.java | 19 +------- .../influxdb/client/ITInfluxQLQueryApi.java | 8 ++-- .../internal/InfluxQLQueryApiImplTest.java | 44 +++++++++---------- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java index 9926b04969..2dbb4daacc 100644 --- a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java +++ b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java @@ -190,7 +190,7 @@ private static Map parseTags(@Nonnull final String value) { StringBuilder currentValue = new StringBuilder(); boolean inValue = false; boolean escaped = false; - boolean firstEscaped = false; + // boolean firstEscaped = false; for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); @@ -208,24 +208,9 @@ private static Map parseTags(@Nonnull final String value) { if (c == '\\') { // start escape sequence - // preserve escape character - if (firstEscaped) { + // don't preserve escape character escaped = true; - firstEscaped = false; continue; - } - if (inValue) { - currentValue.append(c); - } else { - currentKey.append(c); - } - firstEscaped = true; - continue; - } - - if (firstEscaped) { - firstEscaped = false; - continue; } if (!inValue && c == '=') { diff --git a/client/src/test/java/com/influxdb/client/ITInfluxQLQueryApi.java b/client/src/test/java/com/influxdb/client/ITInfluxQLQueryApi.java index b3be45baa5..bee459a0b8 100644 --- a/client/src/test/java/com/influxdb/client/ITInfluxQLQueryApi.java +++ b/client/src/test/java/com/influxdb/client/ITInfluxQLQueryApi.java @@ -105,15 +105,15 @@ void testQueryWithTagsWithEscapedChars() { .addField("free", 10) .addTag("host", "A") .addTag("region", "west") - .addTag("location", "vancouver\\,\\ BC") - .addTag("model\\,\\ uid","droid\\,\\ C3PO") + .addTag("location", "vancouver, BC") + .addTag("model, uid","droid, C3PO") ); Map expectedTags = new HashMap<>(); expectedTags.put("host", "A"); expectedTags.put("region", "west"); - expectedTags.put("location", "vancouver\\,\\ BC"); - expectedTags.put("model\\,\\ uid","droid\\,\\ C3PO"); + expectedTags.put("location", "vancouver, BC"); + expectedTags.put("model, uid","droid, C3PO"); InfluxQLQueryResult result = influxQLQueryApi.query( new InfluxQLQuery("SELECT * FROM \"specialTags\" GROUP BY *", DATABASE_NAME)); diff --git a/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java b/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java index 2fbf059e3c..6199e18f8c 100644 --- a/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java +++ b/client/src/test/java/com/influxdb/client/internal/InfluxQLQueryApiImplTest.java @@ -89,10 +89,10 @@ void readInfluxQLResultWithMalformedAndBoundaryTagCases() throws IOException { assertParsedTags("host=a,", mapOf("host", "a")); assertParsedTags(",host=a", mapOf(",host", "a")); assertParsedTags("a=1,,b=2", mapOf("a", "1", ",b", "2")); - assertParsedTags("a=foo\\", mapOf("a", "foo\\")); - assertParsedTags("k\\\\==v\\\\=1", mapOf("k\\=", "v\\=1")); - assertParsedTags("k\\\\,x=v\\\\,y,b=2", mapOf("k\\,x", "v\\,y", "b", "2")); - assertParsedTags("k\\\\=x", mapOf()); + assertParsedTags("a=foo\\", mapOf("a", "foo")); + assertParsedTags("k\\==v\\=1", mapOf("k=", "v=1")); + assertParsedTags("k\\,x=v\\,y,b=2", mapOf("k,x", "v,y", "b", "2")); + assertParsedTags("k\\=x", mapOf()); } @Test @@ -112,14 +112,14 @@ void readInfluxQLResultWithTagCommas() throws IOException { List testTags = Arrays.asList( "location=Cheb_CZ", //simpleTag "region=us-east-1,host=server1", // standardTags * 2 - "location=Cheb\\\\,\\\\ CZ", // simpleTag with value comma and space + "location=Cheb\\,\\ CZ", // simpleTag with value comma and space "location=Cheb_CZ,branch=Munchen_DE", // multiple tags with underscore - "location=Cheb\\\\,\\\\ CZ,branch=Munchen\\\\,\\\\ DE", // multiple tags with comma and space - "model\\\\,\\\\ uin=C3PO", // tag with comma space in key - "model\\\\,\\\\ uin=Droid\\\\,\\\\ C3PO", // tag with comma space in key and value - "model\\\\,\\\\ uin=Droid\\\\,\\\\ C3PO,location=Cheb\\\\,\\\\ CZ,branch=Munchen\\\\,\\\\ DE", // comma space in key and val - "silly\\\\,\\\\=long\\\\,tag=a\\\\,b\\\\\\\\\\,\\\\ c\\\\,\\\\ d", // multi commas in k and v plus escaped reserved chars - "region=us\\\\,\\\\ east-1,host\\\\,\\\\ name=ser\\\\,\\\\ ver1" // legacy broken tags + "location=Cheb\\,\\ CZ,branch=Munchen\\,\\ DE", // multiple tags with comma and space + "model\\,\\ uin=C3PO", // tag with comma space in key + "model\\,\\ uin=Droid\\,\\ C3PO", // tag with comma space in key and value + "model\\,\\ uin=Droid\\,\\ C3PO,location=Cheb\\,\\ CZ,branch=Munchen\\,\\ DE", // comma space in key and val + "silly\\,\\=long\\,tag=a\\,b\\\\\\,\\ c\\,\\ d", // multi commas in k and v plus escaped reserved chars + "region=us\\,\\ east-1,host\\,\\ name=ser\\,\\ ver1" // legacy broken tags ); Map> expectedTagsMap = Stream.of( @@ -134,7 +134,7 @@ void readInfluxQLResultWithTagCommas() throws IOException { )), // 3. simpleTag with value comma and space new AbstractMap.SimpleImmutableEntry<>(testTags.get(2), - mapOf("location", "Cheb\\,\\ CZ")), + mapOf("location", "Cheb, CZ")), // 4. multiple tags with underscore new AbstractMap.SimpleImmutableEntry<>(testTags.get(3), mapOf( @@ -144,32 +144,32 @@ void readInfluxQLResultWithTagCommas() throws IOException { // 5. multiple tags with comma and space new AbstractMap.SimpleImmutableEntry<>(testTags.get(4), mapOf( - "location", "Cheb\\,\\ CZ", - "branch", "Munchen\\,\\ DE" + "location", "Cheb, CZ", + "branch", "Munchen, DE" )), // 6. tag with comma and space in key new AbstractMap.SimpleImmutableEntry<>(testTags.get(5), - mapOf("model\\,\\ uin", "C3PO")), + mapOf("model, uin", "C3PO")), // 7. tag with comma and space in key and value new AbstractMap.SimpleImmutableEntry<>(testTags.get(6), - mapOf("model\\,\\ uin", "Droid\\,\\ C3PO")), + mapOf("model, uin", "Droid, C3PO")), // 8. comma space in key and val with multiple tags new AbstractMap.SimpleImmutableEntry<>(testTags.get(7), mapOf( - "model\\,\\ uin", "Droid\\,\\ C3PO", - "location", "Cheb\\,\\ CZ", - "branch", "Munchen\\,\\ DE" + "model, uin", "Droid, C3PO", + "location", "Cheb, CZ", + "branch", "Munchen, DE" )), // 9. multiple commas in key and value new AbstractMap.SimpleImmutableEntry<>(testTags.get(8), mapOf( - "silly\\,\\=long\\,tag", "a\\,b\\\\\\,\\ c\\,\\ d" + "silly,=long,tag", "a,b\\, c, d" )), // legacy broken tags new AbstractMap.SimpleImmutableEntry<>(testTags.get(9), mapOf( - "region", "us\\,\\ east-1", - "host\\,\\ name", "ser\\,\\ ver1" + "region", "us, east-1", + "host, name", "ser, ver1" )) ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); From c22549059c9cf3416fe022f905f1316c0cf0875a Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 27 Mar 2026 17:15:23 +0100 Subject: [PATCH 2/3] chore: remove commented line --- .../java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java index 2dbb4daacc..913480d505 100644 --- a/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java +++ b/client/src/main/java/com/influxdb/client/internal/InfluxQLQueryApiImpl.java @@ -190,7 +190,6 @@ private static Map parseTags(@Nonnull final String value) { StringBuilder currentValue = new StringBuilder(); boolean inValue = false; boolean escaped = false; - // boolean firstEscaped = false; for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); From d916c8e83516b2a61a44e62ca60663dc8e458c57 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Fri, 27 Mar 2026 17:23:12 +0100 Subject: [PATCH 3/3] docs: update CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83fcb72090..7812486d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 6.10.2 [2026-03-27] + +### Bug Fixes + +1. [#864](https://github.com/influxdata/influxdb-client-java/pull/864): Correct tags parsing. + - Previous hot fix 6.10.1 used incorrect escapes in testing tag keys and values. + - This fix... + - Uses correctly escaped keys and values + - Updates the tags parser in InfluxQLQueryAPI to handle them correctly + ## 6.10.1 [2026-03-25] ### Bug Fixes