| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HtmlUtil; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | |
| | |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | /** |
| | | * XSS过滤处理 |
| | |
| | | } |
| | | |
| | | // 为空,直接返回 |
| | | String json = IOUtils.toString(super.getInputStream(), "utf-8"); |
| | | String json = IoUtil.read(super.getInputStream(), StandardCharsets.UTF_8); |
| | | if (Validator.isEmpty(json)) |
| | | { |
| | | return super.getInputStream(); |
| | |
| | | |
| | | // xss过滤 |
| | | json = HtmlUtil.cleanHtmlTag(json).trim(); |
| | | final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); |
| | | |
| | | final ByteArrayInputStream bis = IoUtil.toStream(json, StandardCharsets.UTF_8); |
| | | return new ServletInputStream() |
| | | { |
| | | @Override |