jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Add escaping for new lines in AbstractInfluxdbMetricsSender
Date Sat, 27 Feb 2021 16:04:54 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c2f611  Add escaping for new lines in AbstractInfluxdbMetricsSender
2c2f611 is described below

commit 2c2f611ee1578496c7e3c7507864bbb3c32531f3
Author: David Getzlaff <david.getzlaff@t-systems.com>
AuthorDate: Thu Feb 25 11:25:15 2021 +0100

    Add escaping for new lines in AbstractInfluxdbMetricsSender
    
    Contributed by David Getzlaff (david.getzlaff at t-systems.com>)
    
    Closes #645 on github
---
 .../backend/influxdb/AbstractInfluxdbMetricsSender.java        | 10 ++++++++--
 xdocs/changes.xml                                              |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/AbstractInfluxdbMetricsSender.java
b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/AbstractInfluxdbMetricsSender.java
index 7845fc8..a56e9a4 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/AbstractInfluxdbMetricsSender.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/backend/influxdb/AbstractInfluxdbMetricsSender.java
@@ -19,6 +19,7 @@ package org.apache.jmeter.visualizers.backend.influxdb;
 
 /**
  * Base class for {@link InfluxdbMetricsSender}
+ *
  * @since 3.2
  */
 abstract class AbstractInfluxdbMetricsSender implements InfluxdbMetricsSender {
@@ -28,7 +29,11 @@ abstract class AbstractInfluxdbMetricsSender implements InfluxdbMetricsSender
{
      * \ to escape List of special characters : commas , equal sign = spaces
      */
     static final String tagToStringValue(String s) {
-        return s.trim().replaceAll(" ", "\\\\ ").replaceAll(",", "\\\\,").replaceAll("=",
"\\\\=");
+        return s.trim()
+                .replace(" ", "\\ ")
+                .replace(",", "\\,")
+                .replace("=", "\\=")
+                .replace("\n", "\\n");
     }
 
     /**
@@ -36,7 +41,8 @@ abstract class AbstractInfluxdbMetricsSender implements InfluxdbMetricsSender
{
      * \ to escape " character
      */
     static final String fieldToStringValue(String s) {
-        return s.trim().replaceAll("\"", "\\\\\"");
+        return s.trim()
+                .replace("\"", "\\\"");
     }
 
 }
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 96c5edf..4df2d5b 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -165,6 +165,7 @@ Summary
 <ul>
   <li><bug>64318</bug>DNS Cache Manager - custom DNS resolver does not
use system resolver by default</li>
   <li><pr>641</pr>Updated xercesImpl to 2.12.1 (from 2.12.0). Based on
patch by Stefan Seide (stefan at trilobyte-se.de).</li>
+  <li><pr>645</pr>Add escaping for new lines in AbstractInfluxdbMetricsSender.
Contributed by David Getzlaff (david.getzlaff at t-systems.com>)</li>
 </ul>
 
  <!--  =================== Thanks =================== -->
@@ -175,6 +176,7 @@ Summary
 <ul>
   <li>Stefan Seide (stefan at trilobyte-se.de)</li>
   <li>njzukas (github.com/njzukas)</li>
+  <li>David Getzlaff (david.getzlaff at t-systems.com>)</li>
 </ul>
 <p>We also thank bug reporters who helped us improve JMeter.</p>
 <ul>


Mime
View raw message