当前位置:网站首页>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 .
边栏推荐
- Basic differences between Oracle and MySQL (entry level)
- 黑马笔记---Map集合体系
- fastText文本分类
- LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
- 数据的储存
- Fabric.js 右键菜单
- Fabric.js 渐变
- Super detailed pycharm tutorial
- [common error] the DDR type of FPGA device is selected incorrectly
- Record my pytorch installation process and errors
猜你喜欢
视差特效的原理和实现方法
About PROFIBUS: communication backbone network of production plant
Fabric.js 激活输入框
Cultivate primary and secondary school students' love for educational robots
Record my pytorch installation process and errors
el form 表单validate成功后没有执行逻辑
Here comes the chicken soup! Keep this quick guide for data analysts
Gee series: Unit 2 explore datasets
Dark horse notes -- map set system
[bus interface] Axi interface
随机推荐
paddle: ValueError:quality setting only supported for ‘jpeg‘ compression
Cubemx DMA notes
Draw a wave chart_ Digital IC
Fabric.js 更换图片的3种方法(包括更换分组内的图片,以及存在缓存的情况)
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
数据库批量插入数据
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
Basic differences between Oracle and MySQL (entry level)
Oracle和MySQL的基本区别(入门级)
CubeMx DMA笔记
Mysql重点难题(2)汇总
LeetCode 241. Design priorities for operational expressions (divide and conquer / mnemonic recursion / dynamic programming)
Fabric.js 右键菜单
Cultivate primary and secondary school students' love for educational robots
The reason why sizeof (ARR) / sizeof (arr[0]) is used in the function to calculate the length of the array is incorrect
4. Flask cooperates with a tag to link internal routes
Go implements leetcode rotation array
Go GC garbage collection notes (three color mark)
MMAP zero copy knowledge point notes