From 0140e0cdf901d28ddf6cd16859a055e3815e01cc Mon Sep 17 00:00:00 2001 From: Angelo Date: Thu, 13 Aug 2026 09:32:22 +0700 Subject: [PATCH 1/4] fix(point): validate newlines --- src/point.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/point.rs b/src/point.rs index c6423df..44edf38 100644 --- a/src/point.rs +++ b/src/point.rs @@ -259,6 +259,37 @@ impl Point { self.measurement ))); } + // VALIDATION: '\n' characters are not supported + for (k, v) in self.tags() { + if k.contains('\n') || v.contains('\n') { + return Err(Error::Config( + format!( + "tag '{k}' contains a line break which is unsupported in line protocol; point '{}'", + self.measurement + ) + )); + } + } + for (k, v) in self.fields() { + if k.contains('\n') { + return Err(Error::Config( + format!( + "field '{k}' contains a line break which is unsupported in line protocol; point '{}'", + self.measurement + ) + )); + } + if let FieldValue::String(s) = v { + if s.contains('\n') { + return Err(Error::Config( + format!( + "field '{k}' contains a line break which is unsupported in line protocol; point '{}'", + self.measurement + ) + )); + } + } + } // Measurement write_escaped_measurement(buf, &self.measurement); From 5a1a968f867d670a78e290c92e8872b614e2310d Mon Sep 17 00:00:00 2001 From: Angelo Date: Thu, 13 Aug 2026 09:50:56 +0700 Subject: [PATCH 2/4] chore: add changes to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01737ca..a80dacd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.4.0 [unreleased] +### Bug Fixes + +1. [#49](https://github.com/InfluxCommunity/influxdb3-rust/pull/49): Extra validation on `Point#write_line_protocol()` to error out if fields contains any newline (`\n`) character. + ## 0.3.0 [2026-08-27] > ⚠️ This release requires Rust 1.91 or later. From 105d09f00b7c1c7e25edbebf85b7cd2878a4c041 Mon Sep 17 00:00:00 2001 From: Angelo Date: Thu, 27 Aug 2026 17:13:46 +0700 Subject: [PATCH 3/4] test: add tests for linebreak validation --- tests/point_tests.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/point_tests.rs b/tests/point_tests.rs index 4c2bd73..9eff600 100644 --- a/tests/point_tests.rs +++ b/tests/point_tests.rs @@ -80,3 +80,31 @@ fn last_write_wins() { assert_eq!(lp.matches("v=").count(), 1); assert!(lp.contains("v=2i")); } + +#[test] +#[should_panic = "contains a line break"] +fn tag_names_should_reject_newlines() { + Point::new("m") + .tag("t\nag", "value") + .field("v", 1) + .to_line_protocol(Precision::Nanosecond) + .unwrap(); +} +#[test] +#[should_panic = "contains a line break"] +fn tag_values_should_reject_newlines() { + Point::new("m") + .tag("tag", "val\nue") + .field("v", 1) + .to_line_protocol(Precision::Nanosecond) + .unwrap(); +} +#[test] +#[should_panic = "contains a line break"] +fn field_names_should_reject_newlines() { + Point::new("m") + .tag("tag", "value") + .field("fi\neld", 1) + .to_line_protocol(Precision::Nanosecond) + .unwrap(); +} From ef2e8f4f1938acb49fd3d7f11b2f54380a34e7dd Mon Sep 17 00:00:00 2001 From: Ales Pour Date: Thu, 27 Aug 2026 14:15:41 +0200 Subject: [PATCH 4/4] test: add coverage for newlines in string field values --- tests/point_tests.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/point_tests.rs b/tests/point_tests.rs index 9eff600..ae588a4 100644 --- a/tests/point_tests.rs +++ b/tests/point_tests.rs @@ -108,3 +108,12 @@ fn field_names_should_reject_newlines() { .to_line_protocol(Precision::Nanosecond) .unwrap(); } + +#[test] +#[should_panic = "contains a line break"] +fn field_values_should_reject_newlines() { + Point::new("m") + .field("field", "val\nue") + .to_line_protocol(Precision::Nanosecond) + .unwrap(); +}