java - XSS 跨站点脚本不允许在 Spring Boot 应用程序中使用 xls 文件
问题描述
我在我的应用程序中使用 XSS 跨站点脚本。我的应用程序有一个端点,我必须通过邮递员上传 xls 文件。当我尝试到达端点时,XSS 脚本不会让它通过并给出以下错误
2019-08-08 10:47:38|800 [DEBUG] com.vz.stamps.tools.XSSTools - 验证 XSS 的值:[------------------ ----------503127257286871229160750内容处置:表单数据;名称=“文件”;filename="New Microsoft Excel Worksheet.xls"Content-Type: application/vnd.ms-excelPK
这是我的 urlDecode 代码:
public static String urlDecode(String value) {
try {
value = value.replaceAll("%25", " ");
value =URLDecoder.decode(value, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.info("Unable to decode String with UTF8! Trying adifferent encoding", e);
try {
value =URLDecoder.decode(value, StandardCharsets.ISO_8859_1.name());
} catch (UnsupportedEncodingException e1) {
logger.info("Unable to decode String with ISO_8859_1! Trying adifferent encoding", e);
try {
value =URLDecoder.decode(value, StandardCharsets.US_ASCII.name());
} catch (UnsupportedEncodingException e2) {
logger.info("Unable to decode String with US_ASCII! Not trying to decode any further!!!", e);
}
}
} catch (Exception e) {
logger.error("Error decoding String, returning null!!!", e);
return value.replaceAll("%", "");
}
return value;
}
我从邮递员那里得到的价值是:
----------------------------238658527993479868792963Content-Disposition: form-data; name="file"; filename="New Microsoft Excel Worksheet.xls"Content-Type: application/vnd.ms-excelPK
错误 :
URLDecoder:转义 (%) 模式中的非法十六进制字符 - 对于输入字符串:“¿”
解决方案
推荐阅读
- excel - 多个分节符 - 如何仅将页眉和页脚添加到第一个部分?
- entity-framework-core - EF Core:传递给 HasQueryFilter 的委托仅在使用配置类时调用一次。为什么?
- c - C编程:scanf后无意清除了输入缓冲区?
- typescript - Nestjs,我无法从模块的静态函数访问我的环境变量
- excel - 如何设置搜索条件,从数据透视表搜索数据,如果找到一个或所有标准,从数据透视表复制数据并在输出选项卡中过去
- azure-cosmosdb - Pymongo find_one_and_update 返回 null (Azure Cosmos DB)
- python - 如何在一个情节matplotlib中绘制不同的情节
- docker - 无法通过 LAN 连接到 docker 容器,只能连接 localhost
- java - maven 确保 fire 插件没有从依赖项目中选择类
- google-cloud-storage - 谷歌云存储与 HDFS