xuekang
2024-05-11 bac0878349a1db23e7b420ea164e22fb9db73a99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.nuvole.util;
 
import org.apache.commons.lang.CharEncoding;
import org.junit.Test;
 
/**
 * @author ChenLong
 * @version 1.0
 * @ClassName XssUtilTest
 * @date 2019/7/16 18:42
 */
public class XssUtilTest {
 
    @Test
    public void clearXss() throws Exception {
        String val = "<p style=\"text-align: center;\"><strong>qqq<em>qxxxx<span style=\"text-decoration: underline;\">ffffff<span style=\"text-decoration: line-through;\">fffff</span></span></em></strong></p>\n" +
                "<p style=\"text-align: center;\"><strong><em><span style=\"text-decoration: underline;\"><span style=\"text-decoration: line-through;\"><img src=\"https://echftp.yqzhfw.com/ecosphereBaseDev/2019/7/16/0262f69df57f4f68acf763cacd362879.jpg\" alt=\"lalalal\" width=\"1920\" height=\"1080\" /></span></span></em></strong></p>";
        System.out.println(XssUtil.clearXss(val));
    }
 
    @Test
    public void test() throws Exception {
        String b = "aaaa";
        byte[] a = b.getBytes(CharEncoding.ISO_8859_1);
        System.out.println("is a:" + a);
        String s2 = XssUtil.clearXss(new String(a, CharEncoding.ISO_8859_1));
        System.out.println("s2:" + s2);
        System.out.println("s2 byte:" + s2.getBytes(CharEncoding.ISO_8859_1));
    }
 
}