当前位置:网站首页>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 .
边栏推荐
- About PROFIBUS: communication backbone network of production plant
- Super detailed pycharm tutorial
- Online English teaching app open source platform (customized)
- 黑马笔记---Map集合体系
- 线程池批量处理数据
- Mysql重点难题(2)汇总
- Mathematical knowledge -- understanding and examples of fast power
- Feign realizes file uploading and downloading
- Oracle和MySQL的基本区别(入门级)
- 6.网络-基础
猜你喜欢
![Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]](/img/78/a17034d4b77d5c0dbe741f84a8ecd7.jpg)
Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]
![[common error] the DDR type of FPGA device is selected incorrectly](/img/f3/be66bcfafeed581add6d48654dfe34.jpg)
[common error] the DDR type of FPGA device is selected incorrectly

黑马笔记---Map集合体系
![Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]](/img/1e/cf0aa09c2fce2278386f12eae4a6cd.jpg)
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]

Pyechats 1.19 generate a web version of Baidu map

Dark horse notes -- map set system

Disable access to external entities in XML parsing

Go Chan's underlying principles

Solution: the agent throws an exception error

Fabric.js 将本地图像上传到画布背景
随机推荐
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
案例分享|智慧化的西部机场
7.TCP的十一种状态集
Global and Chinese markets for marine selective catalytic reduction systems 2022-2028: Research Report on technology, participants, trends, market size and share
Case sharing | intelligent Western Airport
4. Flask cooperates with a tag to link internal routes
Video cover image setting, put cover images into multiple videos in the simplest way
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
Video multiple effects production, fade in effect and border background are added at the same time
C# 图片显示占用问题
Implementation of go language for deleting duplicate items in sorting array
线程池批量处理数据
Draw a wave chart_ Digital IC
The underlying principle of go map (storage and capacity expansion)
Implementation of leetcode two number addition go
Feign realizes file uploading and downloading
Super detailed pycharm tutorial
[high speed bus] Introduction to jesd204b
Mysql基础---查询(1天学会mysql基础)
Domestic all Chinese automatic test software apifox