| | |
| | | package com.ruoyi.common.filter; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.http.HtmlUtil; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.html.EscapeUtil; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * XSS过滤处理 |
| | |
| | | for (int i = 0; i < length; i++) |
| | | { |
| | | // 防xss攻击和过滤前后空格 |
| | | escapseValues[i] = EscapeUtil.clean(values[i]).trim(); |
| | | escapseValues[i] = HtmlUtil.cleanHtmlTag(values[i]).trim(); |
| | | } |
| | | return escapseValues; |
| | | } |
| | |
| | | |
| | | // 为空,直接返回 |
| | | String json = IOUtils.toString(super.getInputStream(), "utf-8"); |
| | | if (StringUtils.isEmpty(json)) |
| | | if (Validator.isEmpty(json)) |
| | | { |
| | | return super.getInputStream(); |
| | | } |
| | | |
| | | // xss过滤 |
| | | json = EscapeUtil.clean(json).trim(); |
| | | json = HtmlUtil.cleanHtmlTag(json).trim(); |
| | | final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); |
| | | return new ServletInputStream() |
| | | { |