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));
|
}
|
|
}
|