refactor: "UTF-8" -> StandardCharsets.UTF_8.name()
This commit is contained in:
parent
36b24c44da
commit
acb9a7408a
|
@ -63,6 +63,7 @@ import org.json.JSONObject;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -121,7 +122,7 @@ public class ElementUtil {
|
|||
csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName());
|
||||
csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? StandardCharsets.UTF_8.name() : item.getEncoding());
|
||||
if (CollectionUtils.isEmpty(item.getFiles())) {
|
||||
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ " + Translator.get("csv_no_exist") + " ]");
|
||||
} else {
|
||||
|
@ -170,7 +171,7 @@ public class ElementUtil {
|
|||
csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName());
|
||||
csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
|
||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
|
||||
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? StandardCharsets.UTF_8.name() : item.getEncoding());
|
||||
if (CollectionUtils.isEmpty(item.getFiles())) {
|
||||
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + ":[ " + Translator.get("csv_no_exist") + " ]");
|
||||
} else {
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.json.JSONObject;
|
|||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -123,7 +124,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
sampler.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HttpTestSampleGui"));
|
||||
ElementUtil.setBaseParams(sampler, this.getParent(), config, this.getId(), this.getIndex());
|
||||
sampler.setMethod(this.getMethod());
|
||||
sampler.setContentEncoding("UTF-8");
|
||||
sampler.setContentEncoding(StandardCharsets.UTF_8.name());
|
||||
sampler.setFollowRedirects(this.isFollowRedirects());
|
||||
sampler.setUseKeepAlive(true);
|
||||
sampler.setDoMultipart(this.isDoMultipartPost());
|
||||
|
@ -371,14 +372,14 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
try {
|
||||
URL urlObject = new URL(url);
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
||||
if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
||||
sampler.setProperty("HTTPSampler.port", this.getPort());
|
||||
} else if (urlObject.getPort() != -1) {
|
||||
sampler.setPort(urlObject.getPort());
|
||||
}
|
||||
sampler.setProtocol(urlObject.getProtocol());
|
||||
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(urlObject.getFile(), "UTF-8"), "UTF-8"));
|
||||
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(urlObject.getFile(), StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name()));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
|
@ -396,7 +397,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
sampler.setPort(httpConfig.getPort());
|
||||
if (StringUtils.isNotEmpty(httpConfig.getDomain())) {
|
||||
sampler.setDomain(URLDecoder.decode(httpConfig.getDomain(), "UTF-8"));
|
||||
sampler.setDomain(URLDecoder.decode(httpConfig.getDomain(), StandardCharsets.UTF_8.name()));
|
||||
sampler.setProtocol(httpConfig.getProtocol());
|
||||
} else {
|
||||
sampler.setDomain("");
|
||||
|
@ -406,13 +407,13 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
} else {
|
||||
URL urlObject = new URL(this.path);
|
||||
envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
||||
sampler.setProtocol(urlObject.getProtocol());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(envPath) && !envPath.startsWith("/")) {
|
||||
envPath = "/" + envPath;
|
||||
}
|
||||
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8"));
|
||||
sampler.setProperty("HTTPSampler.path", URLDecoder.decode(URLEncoder.encode(envPath, StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name()));
|
||||
}
|
||||
}
|
||||
String envPath = sampler.getPath();
|
||||
|
@ -441,7 +442,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
MSException.throwException("请重新选择环境");
|
||||
}
|
||||
URL urlObject = new URL(url);
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
|
||||
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), StandardCharsets.UTF_8.name()));
|
||||
if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
|
||||
sampler.setProperty("HTTPSampler.port", this.getPort());
|
||||
} else if (urlObject.getPort() != -1) {
|
||||
|
@ -451,11 +452,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getFile();
|
||||
sampler.setProperty("HTTPSampler.path", envPath);
|
||||
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
|
||||
envPath = getRestParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8"));
|
||||
envPath = getRestParameters(URLDecoder.decode(URLEncoder.encode(envPath, StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name()));
|
||||
sampler.setProperty("HTTPSampler.path", envPath);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.getArguments())) {
|
||||
sampler.setProperty("HTTPSampler.path", postQueryParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8")));
|
||||
sampler.setProperty("HTTPSampler.path", postQueryParameters(URLDecoder.decode(URLEncoder.encode(envPath, StandardCharsets.UTF_8.name()), StandardCharsets.UTF_8.name())));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class MsAbstractParser<T> extends ApiImportAbstractParser<T> {
|
||||
|
@ -52,7 +53,7 @@ public abstract class MsAbstractParser<T> extends ApiImportAbstractParser<T> {
|
|||
if (split.length > 1) {
|
||||
try {
|
||||
String queryParams = split[1];
|
||||
queryParams = URLDecoder.decode(queryParams, "UTF-8");
|
||||
queryParams = URLDecoder.decode(queryParams, StandardCharsets.UTF_8.name());
|
||||
String[] params = queryParams.split("&");
|
||||
for (String param : params) {
|
||||
String[] kv = param.split("=");
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -58,8 +59,8 @@ public class ESBParser extends EsbAbstractParser {
|
|||
out = response.getOutputStream();
|
||||
response.reset();
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()) + ".xlsx");
|
||||
wb.write(out);
|
||||
wb.close();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -85,7 +86,7 @@ public class HarParser extends HarAbstractParser {
|
|||
}
|
||||
|
||||
try {
|
||||
url = URLDecoder.decode(url, "UTF-8");
|
||||
url = URLDecoder.decode(url, StandardCharsets.UTF_8.name());
|
||||
if (url.contains("?")) {
|
||||
url = url.split("\\?")[0];
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.dom4j.io.XMLWriter;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +39,7 @@ public class EsbDataParser {
|
|||
// 设置XML文档格式
|
||||
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
|
||||
// 设置XML编码方式,即是用指定的编码方式保存XML文档到字符串(String),这里也可以指定为GBK或是ISO8859-1
|
||||
outputFormat.setEncoding("UTF-8");
|
||||
outputFormat.setEncoding(StandardCharsets.UTF_8.name());
|
||||
//outputFormat.setSuppressDeclaration(true); //是否生产xml头
|
||||
outputFormat.setIndent(true); //设置是否缩进
|
||||
outputFormat.setNewlines(true); //设置是否换行
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.dom4j.io.XMLWriter;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class TcpTreeTableDataParser {
|
|||
// 设置XML文档格式
|
||||
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
|
||||
// 设置XML编码方式,即是用指定的编码方式保存XML文档到字符串(String),这里也可以指定为GBK或是ISO8859-1
|
||||
outputFormat.setEncoding("UTF-8");
|
||||
outputFormat.setEncoding(StandardCharsets.UTF_8.name());
|
||||
//outputFormat.setSuppressDeclaration(true); //是否生产xml头
|
||||
outputFormat.setIndent(true); //设置是否缩进
|
||||
outputFormat.setNewlines(true); //设置是否换行
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -46,7 +47,7 @@ public class DataFormattingUtil {
|
|||
//获取要转化的文件
|
||||
List<String> attachmentFilePathList = new ArrayList<>();
|
||||
try {
|
||||
Document doc = EngineSourceParserFactory.getDocument(new ByteArrayInputStream(jmx.getBytes("utf-8")));
|
||||
Document doc = EngineSourceParserFactory.getDocument(new ByteArrayInputStream(jmx.getBytes(StandardCharsets.UTF_8.name())));
|
||||
Element root = doc.getRootElement();
|
||||
Element rootHashTreeElement = root.element(ElementConstants.HASH_TREE);
|
||||
List<Element> innerHashTreeElementList = rootHashTreeElement.elements(ElementConstants.HASH_TREE);
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.json.JSONObject;
|
|||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -160,7 +161,7 @@ public class XMLUtil {
|
|||
|
||||
public static Document stringToDocument(String xml) {
|
||||
try {
|
||||
return EngineSourceParserFactory.getDocument(new ByteArrayInputStream(xml.getBytes("utf-8")));
|
||||
return EngineSourceParserFactory.getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8.name())));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
return null;
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.json.JSONObject;
|
|||
import javax.script.ScriptEngine;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -483,7 +484,7 @@ public class MockApiUtils {
|
|||
}
|
||||
outSteam.close();
|
||||
inputStream.close();
|
||||
result = new String(outSteam.toByteArray(), "UTF-8");
|
||||
result = new String(outSteam.toByteArray(), StandardCharsets.UTF_8.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
@ -504,10 +505,10 @@ public class MockApiUtils {
|
|||
byte buffer[] = getRequestPostBytes(request);
|
||||
String charEncoding = request.getCharacterEncoding();
|
||||
if (charEncoding == null) {
|
||||
charEncoding = "UTF-8";
|
||||
charEncoding = StandardCharsets.UTF_8.name();
|
||||
}
|
||||
if (buffer == null) {
|
||||
return "";
|
||||
return StringUtils.EMPTY;
|
||||
} else {
|
||||
return new String(buffer, charEncoding);
|
||||
}
|
||||
|
@ -520,7 +521,7 @@ public class MockApiUtils {
|
|||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(
|
||||
request.getInputStream(), "UTF-8"));
|
||||
request.getInputStream(), StandardCharsets.UTF_8.name()));
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
recieveData.append(inputLine);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -1105,7 +1106,7 @@ public class MockConfigService {
|
|||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
XMLUtil.setExpandEntityReferencesFalse(documentBuilderFactory);
|
||||
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
|
||||
builder.parse(new InputSource(new ByteArrayInputStream(message.getBytes("utf-8"))));
|
||||
builder.parse(new InputSource(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8.name()))));
|
||||
isXml = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
|
@ -15,7 +16,7 @@ import java.security.MessageDigest;
|
|||
*/
|
||||
public class CodingUtil {
|
||||
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
private static final String UTF_8 = StandardCharsets.UTF_8.name();
|
||||
|
||||
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.apache.commons.codec.binary.Base64;
|
|||
|
||||
import javax.crypto.Cipher;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
|
@ -13,7 +14,7 @@ import java.security.spec.X509EncodedKeySpec;
|
|||
|
||||
public class RsaUtil {
|
||||
|
||||
public static final String CHARSET = "UTF-8";
|
||||
public static final String CHARSET = StandardCharsets.UTF_8.name();
|
||||
public static final String RSA_ALGORITHM = "RSA";
|
||||
|
||||
private static RsaKey rsaKey;
|
||||
|
|
|
@ -20,6 +20,7 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -62,7 +63,7 @@ public class TcpTreeTableDataParser {
|
|||
// 设置XML文档格式
|
||||
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
|
||||
// 设置XML编码方式,即是用指定的编码方式保存XML文档到字符串(String),这里也可以指定为GBK或是ISO8859-1
|
||||
outputFormat.setEncoding("UTF-8");
|
||||
outputFormat.setEncoding(StandardCharsets.UTF_8.name());
|
||||
//outputFormat.setSuppressDeclaration(true); //是否生产xml头
|
||||
outputFormat.setIndent(true); //设置是否缩进
|
||||
outputFormat.setNewlines(true); //设置是否换行
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.xml.sax.helpers.XMLFilterImpl;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -179,7 +180,7 @@ public class XMLUtils {
|
|||
|
||||
public static Document stringToDocument(String xml) {
|
||||
try {
|
||||
return getDocument(new ByteArrayInputStream(xml.getBytes("utf-8")));
|
||||
return getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8.name())));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
return null;
|
||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -59,8 +60,8 @@ public class EasyExcelExporter {
|
|||
public void buildExportResponse(HttpServletResponse response, String fileName) {
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()) + ".xlsx");
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(e.getMessage());
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|||
import javax.annotation.Resource;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -161,7 +162,7 @@ public class MailNoticeSender extends AbstractNoticeSender {
|
|||
public JavaMailSenderImpl getMailSender(Map<String, String> paramMap) {
|
||||
Properties props = new Properties();
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setDefaultEncoding(StandardCharsets.UTF_8.name());
|
||||
javaMailSender.setProtocol("smtp");
|
||||
javaMailSender.setHost(paramMap.get(ParamConstants.MAIL.SERVER.getValue()));
|
||||
javaMailSender.setPort(Integer.parseInt(paramMap.get(ParamConstants.MAIL.PORT.getValue())));
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.apache.http.impl.client.HttpClients;
|
|||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,7 @@ public class WxChatbotClient {
|
|||
}
|
||||
HttpPost httppost = new HttpPost(webhook);
|
||||
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
|
||||
StringEntity se = new StringEntity(message.toJsonString(), "utf-8");
|
||||
StringEntity se = new StringEntity(message.toJsonString(), StandardCharsets.UTF_8.name());
|
||||
httppost.setEntity(se);
|
||||
|
||||
SendResult sendResult = new SendResult();
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -302,7 +303,7 @@ public class BaseUserService {
|
|||
|
||||
/*修改当前用户用户密码*/
|
||||
private User updateCurrentUserPwd(EditPassWordRequest request) {
|
||||
String oldPassword = CodingUtil.md5(request.getPassword(), "utf-8");
|
||||
String oldPassword = CodingUtil.md5(request.getPassword(), StandardCharsets.UTF_8.name());
|
||||
String newPassword = request.getNewpassword();
|
||||
String newPasswordMd5 = CodingUtil.md5(newPassword);
|
||||
if (StringUtils.equals(oldPassword, newPasswordMd5)) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.File;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
|
@ -67,7 +68,7 @@ public class ResourceService {
|
|||
|
||||
public String encodeFileName(String fileName) {
|
||||
try {
|
||||
return URLEncoder.encode(fileName, "UTF-8");
|
||||
return URLEncoder.encode(fileName, StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LogUtil.error(e);
|
||||
return fileName;
|
||||
|
@ -76,7 +77,7 @@ public class ResourceService {
|
|||
|
||||
public String decodeFileName(String fileName) {
|
||||
try {
|
||||
return URLDecoder.decode(fileName, "UTF-8");
|
||||
return URLDecoder.decode(fileName, StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LogUtil.error(e);
|
||||
return fileName;
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.commons.utils.LogUtil;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -55,8 +56,8 @@ public class EasyExcelExporter {
|
|||
public void buildExportResponse(HttpServletResponse response, String fileName) {
|
||||
try {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()) + ".xlsx");
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(e.getMessage());
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -504,7 +505,7 @@ public class UserService {
|
|||
|
||||
/*修改当前用户用户密码*/
|
||||
private User updateCurrentUserPwd(EditPassWordRequest request) {
|
||||
String oldPassword = CodingUtil.md5(request.getPassword(), "utf-8");
|
||||
String oldPassword = CodingUtil.md5(request.getPassword(), StandardCharsets.UTF_8.name());
|
||||
String newPassword = request.getNewpassword();
|
||||
String newPasswordMd5 = CodingUtil.md5(newPassword);
|
||||
if (StringUtils.equals(oldPassword, newPasswordMd5)) {
|
||||
|
|
|
@ -73,6 +73,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -1377,9 +1378,9 @@ public class TestCaseService {
|
|||
public void testCaseXmindTemplateExport(String projectId, String importType, HttpServletResponse response) {
|
||||
try {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
boolean isUseCustomId = trackProjectService.useCustomNum(projectId);
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("思维导图用例模版", "UTF-8") + ".xmind");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("思维导图用例模版", StandardCharsets.UTF_8.name()) + ".xmind");
|
||||
String fileName = null;
|
||||
if (StringUtils.equals(importType, ExcelImportType.Update.name())) {
|
||||
fileName = "xmind_update.xml";
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.springframework.util.MultiValueMap;
|
|||
|
||||
import java.io.File;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -363,7 +364,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
|
|||
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + name));
|
||||
} else if (path.contains("/resource/md/get")) { // 新数据走这里
|
||||
String name = path.substring(path.indexOf("/resource/md/get") + 26);
|
||||
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + URLDecoder.decode(name, "UTF-8")));
|
||||
files.add(new File(FileUtils.MD_IMAGE_DIR + "/" + URLDecoder.decode(name, StandardCharsets.UTF_8.name())));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -417,7 +417,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
try {
|
||||
while (matcher.find()) {
|
||||
String url = matcher.group(1);
|
||||
result = URLDecoder.decode(url, "UTF-8");
|
||||
result = URLDecoder.decode(url, StandardCharsets.UTF_8.name());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
return targetStr;
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.json.XML;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class XmindLegacy {
|
|||
}
|
||||
// 去除title中svg:width属性
|
||||
xmlContent = xmlContent.replaceAll("<title svg:width=\"[0-9]*\">", "<title>");
|
||||
Document document = XmlUtils.getDocument(new ByteArrayInputStream(xmlContent.getBytes("utf-8")));// 读取XML文件,获得document对象
|
||||
Document document = XmlUtils.getDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8.name())));// 读取XML文件,获得document对象
|
||||
Element root = document.getRootElement();
|
||||
List<Node> topics = root.selectNodes("//topic");
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class XmindLegacy {
|
|||
xmlComments = xmlComments.replace("xmlns=\"urn:xmind:xmap:xmlns:comments:2.0\"", "");
|
||||
|
||||
// 添加评论到content中
|
||||
Document commentDocument = XmlUtils.getDocument(new ByteArrayInputStream(xmlComments.getBytes("utf-8")));
|
||||
Document commentDocument = XmlUtils.getDocument(new ByteArrayInputStream(xmlComments.getBytes(StandardCharsets.UTF_8.name())));
|
||||
List<Node> commentsList = commentDocument.selectNodes("//comment");
|
||||
|
||||
for (Node topic : topics) {
|
||||
|
@ -102,7 +103,7 @@ public class XmindLegacy {
|
|||
* @throws Exception
|
||||
*/
|
||||
private static String removeTopicsFromString(String xmlContent) throws Exception {
|
||||
Document doc = XmlUtils.getDocument(new ByteArrayInputStream(xmlContent.getBytes("utf-8")));
|
||||
Document doc = XmlUtils.getDocument(new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8.name())));
|
||||
if (doc != null) {
|
||||
Element root = doc.getRootElement();
|
||||
List<Element> childrenElement = root.elements();
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -37,9 +38,9 @@ public class XmindExportUtil {
|
|||
IWorkbook workBook = this.createXmindByTestCase(rootXmind);
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
try {
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("TestCaseExport", "UTF-8") + ".xmind");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("TestCaseExport", StandardCharsets.UTF_8.name()) + ".xmind");
|
||||
workBook.save(response.getOutputStream());
|
||||
// EasyExcel.write(response.getOutputStream(), this.clazz).registerWriteHandler(horizontalCellStyleStrategy).sheet(sheetName).doWrite(data);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
|
Loading…
Reference in New Issue