当前位置:网站首页>Disable access to external entities in XML parsing
Disable access to external entities in XML parsing
2022-07-02 05:17:00 【◢◤】
- Use SAXReader Read XML data
SAXReader saxReader = new SAXReader();
Document userDocument = null;
try {
// Read xml The data is Document object
Document document = saxReader.read(new ByteArrayInputStream(xmlData.getBytes(StandardCharsets.UTF_8)));
String signatureContent = document.getRootElement().element("signatureContent").getData().toString();
// Base64 Parse and get data
byte[] byteData = Base64.decode(signatureContent);
String data = new String(byteData, StandardCharsets.UTF_8);
userDocument = saxReader.read(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)));
} catch (DocumentException e) {
}
- Use SonarLint Scan code prompt Disable access to external entities in XML parsing, Remind that risks are prohibited in XML Accessing external entities in parsing
// close DTD analysis
SAXReader saxReader = SAXReader.createDefault();
Document userDocument = null;
try {
// Read xml The data is Document object
Document document = saxReader.read(new ByteArrayInputStream(xmlData.getBytes(StandardCharsets.UTF_8)));
String signatureContent = document.getRootElement().element("signatureContent").getData().toString();
// Base64 Parse and get data
byte[] byteData = Base64.decode(signatureContent);
String data = new String(byteData, StandardCharsets.UTF_8);
userDocument = saxReader.read(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)));
} catch (DocumentException e) {
result.addElement("status").addText("1");
result.addElement("failReason").addText(e.getMessage());
log.error(" analysis xml The data of failure : " + e.getMessage(), e);
}
Use SAXReader.createDefault() To generate a parser , The settings inside are turned off DTO analysis .
边栏推荐
- Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
- Gee: create a new feature and set corresponding attributes
- Save the CDA from the disc to the computer
- [common error] the DDR type of FPGA device is selected incorrectly
- Fabric.js 居中元素
- 数据库问题汇总
- Record my pytorch installation process and errors
- Summary of MySQL key challenges (2)
- There are duplicate elements in leetcode. Go implementation
猜你喜欢
摆正元素(带过渡动画)
7.TCP的十一种状态集
Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
Summary of database problems
Fabric.js 激活输入框
LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
Cubemx DMA notes
视差特效的原理和实现方法
【pyinstaller】_get_sysconfigdata_name() missing 1 required positional argument: ‘check_exists‘
Fabric.js 渐变
随机推荐
Mathematical knowledge (Euler function)
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
Leetcode18题 【四数之和】递归解法
Solution: the agent throws an exception error
Implementation of leetcode two number addition go
国产全中文-自动化测试软件Apifox
Knowledge arrangement about steam Education
Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
数据库问题汇总
leetcode存在重复元素go实现
Pyflink writes MySQL examples with JDBC
ERP management system development and design existing source code
[common error] the DDR type of FPGA device is selected incorrectly
Global and Chinese market of insulin pens 2022-2028: Research Report on technology, participants, trends, market size and share
Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
Global and Chinese market of impact roll 2022-2028: Research Report on technology, participants, trends, market size and share
Fabric.js 3个api设置画布宽高
Gee series: Unit 2 explore datasets
Fabric.js 背景不受视口变换影响
Fabric.js 将本地图像上传到画布背景