From 4cc0fd0e24fcf37c2e474b287337806724e22c51 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 28 Dec 2020 12:54:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=20url=20encoder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #872 --- .../api/parse/old/JmeterDocumentParser.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/parse/old/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/api/parse/old/JmeterDocumentParser.java index c648df516b..f800316d5c 100644 --- a/backend/src/main/java/io/metersphere/api/parse/old/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/old/JmeterDocumentParser.java @@ -18,6 +18,8 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.ByteArrayInputStream; import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; @@ -154,7 +156,14 @@ public class JmeterDocumentParser { if (!StringUtils.equals("?", u)) { u += "&"; } - u += k + "=" + ScriptEngineUtils.calculate(v); + v = ScriptEngineUtils.calculate(v); + // urlencoder + try { + v = URLEncoder.encode(v, "UTF-8"); + } catch (UnsupportedEncodingException e) { + LogUtil.error(e); + } + u += k + "=" + v; return u; }); ele.setTextContent(url + ((params != null && !params.equals("?")) ? params : ""));