All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.twelvet.xss.core.XssCleaner Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package cn.twelvet.xss.core;

import cn.twelvet.xss.exception.XssType;
import cn.twelvet.xss.utils.XssUtil;
import org.jsoup.Jsoup;

/**
 * xss 清理器
 *
 * @author twelvet
 */
public interface XssCleaner {

	/**
	 * 清理 html
	 * @param html html
	 * @return 清理后的数据
	 */
	default String clean(String html) {
		return clean(html, XssType.FORM);
	}

	/**
	 * 清理 html
	 * @param html html
	 * @param type XssType
	 * @return 清理后的数据
	 */
	String clean(String html, XssType type);

	/**
	 * 判断输入是否安全
	 * @param html html
	 * @return 是否安全
	 */
	default boolean isValid(String html) {
		return Jsoup.isValid(html, XssUtil.WHITE_LIST);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy