- public class SecurityString {
-
- public static String getHtml(String str) {
- //过滤敏感字符
- str = filter(str);
- if (str != null) {
- return str.replaceAll("\r\n", "<BR>");
- } else {
- return " ";
- }
- }
- /**
- * 防止跨站脚本攻击
- * 过滤敏感字符
- * 将HTML特殊字符转换为相应的实体字符。
- */
- public static String filter(String value) {
-
- if (value == null || value.length() == 0) {
- return value;
- }
-
- StringBuffer result = null;
- String filtered = null;
- for (int i = 0; i < value.length(); i++) {
- filtered = null;
- switch (value.charAt(i)) {
- case '<' :
- filtered = "<";
- break;
- case '>' :
- filtered = ">";
- break;
- case '&' :
- filtered = "&";
- break;
- case '"' :
- filtered = """;
- break;
- case '\'' :
- filtered = "'";
- break;
- }
-
- if (result == null) {
- if (filtered != null) {
- result = new StringBuffer(value.length() + 50);
- if (i > 0) {
- result.append(value.substring(0, i));
- }
- result.append(filtered);
- }
- } else {
- if (filtered == null) {
- result.append(value.charAt(i));
- } else {
- result.append(filtered);
- }
- }
- }
- return result == null ? value : result.toString();
- }
- /**
- * 防止SQL注入
- * 验证字符类型不能包含特殊字
- */
- public static boolean checkNonlicetCharacters(String string) {
- boolean flag = true;
- // 不许出现单引号
- if (string != null && string.indexOf("'") > 0) {
- flag = false;
- }
-
- return flag;
- }
- /**
- * 防止SQL注入
- */
- public static String getValidSQLPara(String string) {
- if (string == null || string.length() == 0) {
- return string;
- }
- return string.replaceAll("'", "''");
- }
-
- }
分享到:
相关推荐
java视频上传,转码,截图,播放实现java视频上传,转码,截图,播放实现java视频上传,转码,截图,播放实现
此代码不包含上传视频到oss存储.
SQL注入字符转换器。ASCII码、URL等字符转换软件。
这是一个JAVA乱码的解决代码
h264转码MP4 支持html5播放格式 示例代码: H264TrackImpl h264TrackImpl = new H264TrackImpl(new FileDataSourceImpl("C://a.264")); Movie movie = new Movie(); movie.addTrack(h264TrackImpl); Container ...
java转码 工具类,
java -jar "encoding.jar" the first is the directory store your initial files in any encoding style the second is the directory you want to store the new files the third is the encoding name of your ...
java使用ffmpeg实现视频转码
Java 程序转码(UTF-8)Java 据考察,简单易用、。
NULL 博文链接:https://gang-zai.iteye.com/blog/649655
ajax转码代码,网页端和Java端的使用方法
FFMPEG工程浩大,可以参考的书籍又不是很多...尽管该视频转码器的代码十分简单,但是几乎包含了使用FFMPEG转码一个视频所有必备的API。十分适合FFmpeg的初学者。 工程基于VC2010。 使用了2014.5.6版本的FFmpeg类库。
java读写excel包括utf8转码为可识别汉字gbk,jxl方式读取excel,生成一个新的excel
基于Java的RTSP服务源代码 支持RTP/UDP和RTP/TCP模式的VLC播放源码
java视频上传,转码,截图,播放实现,包含数据库在里面
java转码工具,可以在GB2312和UTF-8码之间进行转换,很好用的!
ffmpeg 音视频转码代码,在前人基础上修改,感谢CSDN。
音频文件转码java开发,基于jave开源技术。 音频文件转码java开发,基于jave开源技术。
JAVA 视频转码FLV 1.视频转化为在线播放格式。 2.支持视频截图。
1. 这个曾经是安全领域涉及到SQL注入破解屏蔽字符串的方法之一,但是现在已经很少用了 2. 这曾经是入侵大型网站(特别是交易类网站的)的黑客钓鱼时隐藏实际URL的工具. 在09年之前的很流行的搜索框漏洞就可以利用框架...