当前位置:网站首页>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 .
边栏推荐
- 6.30 year end summary, end of student age
- Dark horse notes -- Set Series Collection
- Super detailed pycharm tutorial
- 7.1 Résumé du concours de simulation
- Domestic all Chinese automatic test software apifox
- 线程池批量处理数据
- 黑马笔记---Set系列集合
- [opencv] image binarization
- Fabric.js 3个api设置画布宽高
- [high speed bus] Introduction to jesd204b
猜你喜欢

Dark horse notes -- Set Series Collection

Fabric.js IText 上标和下标

CubeMx DMA笔记

LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
![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]

06 decorator mode

Fabric.js 精简JSON

LS1046nfs挂载文件系统

Go Chan's underlying principles
![[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
随机推荐
Gee series: Unit 4 data import and export in Google Earth engine
Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
Fabric.js IText 手动设置斜体
Gee: create a new feature and set corresponding attributes
Super detailed pycharm tutorial
Nodejs (03) -- custom module
How to configure PostgreSQL 12.9 to allow remote connections
Leetcode 18 problem [sum of four numbers] recursive solution
Ansible installation and use
从数组中找出和为目标的下标
Global and Chinese market of cell culture freezers 2022-2028: Research Report on technology, participants, trends, market size and share
Feign realizes file uploading and downloading
视差特效的原理和实现方法
Johnson–Lindenstrauss Lemma(2)
Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
Gee: analyze the change of spatial centroid of remote sensing image [centroid acquisition analysis]
Implementation of leetcode two number addition go
LeetCode 1175. 质数排列(质数判断+组合数学)
Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
Disable access to external entities in XML parsing