View | Details | Raw Unified | Return to bug 64624
Collapse All | Expand All

(-)a/src/core/src/main/java/org/apache/jmeter/report/dashboard/JsonizerVisitor.java (-2 / +3 lines)
Lines 20-32 package org.apache.jmeter.report.dashboard; Link Here
20
import java.util.HashMap;
20
import java.util.HashMap;
21
import java.util.Map;
21
import java.util.Map;
22
22
23
import org.apache.commons.text.StringEscapeUtils;
24
import org.apache.jmeter.report.core.JsonUtil;
23
import org.apache.jmeter.report.core.JsonUtil;
25
import org.apache.jmeter.report.processor.ListResultData;
24
import org.apache.jmeter.report.processor.ListResultData;
26
import org.apache.jmeter.report.processor.MapResultData;
25
import org.apache.jmeter.report.processor.MapResultData;
27
import org.apache.jmeter.report.processor.ResultData;
26
import org.apache.jmeter.report.processor.ResultData;
28
import org.apache.jmeter.report.processor.ResultDataVisitor;
27
import org.apache.jmeter.report.processor.ResultDataVisitor;
29
import org.apache.jmeter.report.processor.ValueResultData;
28
import org.apache.jmeter.report.processor.ValueResultData;
29
30
import com.fasterxml.jackson.core.io.JsonStringEncoder;
30
/**
31
/**
31
 * The class JsonizerVisitor provides a visitor that can get json-like string
32
 * The class JsonizerVisitor provides a visitor that can get json-like string
32
 * from ResultData.
33
 * from ResultData.
Lines 96-102 public class JsonizerVisitor implements ResultDataVisitor<String> { Link Here
96
            Object value = valueResult.getValue();
97
            Object value = valueResult.getValue();
97
            result = String.valueOf(value);
98
            result = String.valueOf(value);
98
            if (value instanceof String) {
99
            if (value instanceof String) {
99
                result = '"' + StringEscapeUtils.escapeEcmaScript(result.replace('\"', '\'')) + '"';
100
                result = '"' + new String(JsonStringEncoder.getInstance().quoteAsString(result)) + '"';
100
            }
101
            }
101
        }
102
        }
102
        return result;
103
        return result;
(-)a/src/core/src/main/java/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java (-3 / +9 lines)
Lines 24-29 import org.apache.jmeter.report.utils.MetricUtils; Link Here
24
import org.apache.jmeter.samplers.SampleSaveConfiguration;
24
import org.apache.jmeter.samplers.SampleSaveConfiguration;
25
import org.apache.jmeter.util.JMeterUtils;
25
import org.apache.jmeter.util.JMeterUtils;
26
26
27
import com.fasterxml.jackson.core.io.JsonStringEncoder;
28
27
/**
29
/**
28
 * <p>
30
 * <p>
29
 * The class ErrorSummaryConsumer provides a consumer that calculates error
31
 * The class ErrorSummaryConsumer provides a consumer that calculates error
Lines 89-95 public class ErrorsSummaryConsumer extends AbstractSummaryConsumer<Long> { Link Here
89
        String responseCode = sample.getResponseCode();
91
        String responseCode = sample.getResponseCode();
90
        String responseMessage = sample.getResponseMessage();
92
        String responseMessage = sample.getResponseMessage();
91
        String key = responseCode + (!StringUtils.isEmpty(responseMessage) ?
93
        String key = responseCode + (!StringUtils.isEmpty(responseMessage) ?
92
                 "/" + StringEscapeUtils.escapeJson(StringEscapeUtils.escapeHtml4(responseMessage)) : "");
94
                 "/" + escapeJson(responseMessage) : "");
93
        if (MetricUtils.isSuccessCode(responseCode) ||
95
        if (MetricUtils.isSuccessCode(responseCode) ||
94
                (StringUtils.isEmpty(responseCode) &&
96
                (StringUtils.isEmpty(responseCode) &&
95
                        !StringUtils.isEmpty(sample.getFailureMessage()))) {
97
                        !StringUtils.isEmpty(sample.getFailureMessage()))) {
Lines 97-108 public class ErrorsSummaryConsumer extends AbstractSummaryConsumer<Long> { Link Here
97
            if (ASSERTION_RESULTS_FAILURE_MESSAGE) {
99
            if (ASSERTION_RESULTS_FAILURE_MESSAGE) {
98
                String msg = sample.getFailureMessage();
100
                String msg = sample.getFailureMessage();
99
                if (!StringUtils.isEmpty(msg)) {
101
                if (!StringUtils.isEmpty(msg)) {
100
                    key = StringEscapeUtils.escapeJson(StringEscapeUtils.escapeHtml4(msg));
102
                    key = escapeJson(msg);
101
                }
103
                }
102
            }
104
            }
103
        }
105
        }
104
        return key;
106
        return key;
105
    }
107
    }
108
109
    private static String escapeJson(String responseMessage) {
110
        return new String(JsonStringEncoder.getInstance().quoteAsString(StringEscapeUtils.escapeHtml4(responseMessage)));
111
    }
112
106
    /*
113
    /*
107
     * (non-Javadoc)
114
     * (non-Javadoc)
108
     *
115
     *
109
- 

Return to bug 64624