当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Gee series: Unit 2 explore datasets
Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
Gee: use of common mask functions in remote sensing image processing [updatemask]
Differential identities (help find mean, variance, and other moments)
Black Horse Notes - - set Series Collection
视差特效的原理和实现方法
Knowledge arrangement about steam Education
Fabric.js 将本地图像上传到画布背景
6.网络-基础
Using QA band and bit mask in Google Earth engine
随机推荐
06 decorator mode
Nodejs (03) -- custom module
Ansible installation and use
Draw a wave chart_ Digital IC
删除排序数组中的重复项go语言实现
LeetCode 241. Design priorities for operational expressions (divide and conquer / mnemonic recursion / dynamic programming)
No logic is executed after the El form is validated successfully
el-cascader回显只选中不显示的问题
el form 表单validate成功后没有执行逻辑
Pyechart1.19 national air quality exhibition
[common error] the DDR type of FPGA device is selected incorrectly
Essence and physical meaning of convolution (deep and brief understanding)
Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
Knowledge arrangement about steam Education
7.1 Résumé du concours de simulation
Gee: create a new feature and set corresponding attributes
Pyflink writes MySQL examples with JDBC
Gee: remote sensing image composite and mosaic
Lay the foundation for children's programming to become a basic discipline
Mathematical knowledge (Euler function)