当前位置:网站首页>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 8 time series analysis in Google Earth engine [time series]
- Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
- There are duplicate elements in leetcode. Go implementation
- 案例分享|智慧化的西部机场
- 操作符详解
- 视差特效的原理和实现方法
- Gee: find the spatial distribution and corresponding time of the "greenest" in the Yellow River Basin in 2020 [pixel by pixel analysis]
- 删除排序数组中的重复项go语言实现
- Collectors.groupingBy 排序
- Gee: explore the change of water area in the North Canal basin over the past 30 years [year by year]
猜你喜欢

数据库问题汇总

Gee series: Unit 4 data import and export in Google Earth engine

Knowledge arrangement about steam Education

Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
![Gee: explore the characteristics of precipitation change in the Yellow River Basin in the past 10 years [pixel by pixel analysis]](/img/ff/59956c2323567cc614458a2bccb642.jpg)
Gee: explore the characteristics of precipitation change in the Yellow River Basin in the past 10 years [pixel by pixel analysis]

Nodejs (02) - built in module

C# 基于MQTTNet的服务端与客户端通信案例

4. Flask cooperates with a tag to link internal routes

How to configure PostgreSQL 12.9 to allow remote connections

Dark horse notes -- Set Series Collection
随机推荐
Fabric.js 自由绘制矩形
Pyflink writes MySQL examples with JDBC
Fabric.js 激活输入框
在{{}}中拼接字符
Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]
Briefly introduce chown command
paddle: ValueError:quality setting only supported for ‘jpeg‘ compression
There are duplicate elements in leetcode. Go implementation
2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
Domestic all Chinese automatic test software apifox
Line by line explanation of yolox source code of anchor free series network (7) -- obj in head_ loss、Cls_ Loss and reg_ Calculation and reverse transmission of loss I
el form 表单validate成功后没有执行逻辑
Knowledge arrangement about steam Education
Preparation for writing SAP ui5 applications using typescript
js面试收藏试题1
LeetCode 1175. Prime number arrangement (prime number judgment + Combinatorial Mathematics)
[high speed bus] Introduction to jesd204b
How to make an RPM file
Basic differences between Oracle and MySQL (entry level)
Map in JS (including leetcode examples)