impl ::influxdb2::models::WriteDataPoint for QuoteStrings {
fn write_data_point_to<W>(&self, mut w: W) -> std::io::Result<()> where W: std::io::Write {
w.write_all(format!("{},", "quote_strings").as_bytes())?;
w.write_all(format!("{}", "string_tag").as_bytes())?;
w.write_all(b"=")?;
w.write_all(<String as ::influxdb2::writable::KeyWritable>::encode_key(&self.string_tag).into_bytes().as_slice())?;
w.write_all(b" ")?;
w.write_all(format!("{}", "string_field").as_bytes())?;
w.write_all(b"=")?;
w.write_all(<String as ::influxdb2::writable::ValueWritable>::encode_value(&self.string_field).into_bytes().as_slice())?;
w.write_all(b" ")?;
w.write_all(<i64 as ::influxdb2::writable::TimestampWritable>::encode_timestamp(&self.time).into_bytes().as_slice())?;
w.write_all(b"\n")?;
Ok(())
}
}
Currently, the KeyWritable just clones the string, and the ValueWritable implementation formats the string with escaped quotes surrounding it. Both would result in errors if the values contain quotes.
Strings that contain quotes aren't properly escaped and cause writes to fail.
Minimal example
expands to:
Currently, the
KeyWritable
just clones the string, and theValueWritable
implementation formats the string with escaped quotes surrounding it. Both would result in errors if the values contain quotes.https://docs.influxdata.com/influxdb/v1/write_protocols/line_protocol_reference/#special-characters Looks like there's a few other characters that need escaping too.
I'd be happy to add a fix for this and open a PR some time next week