夸父追日

飞蛾扑火
本blog很少更新
 
 

常用链接

  • 我的随笔
  • 我的评论
  • 我的参与
  • 最新评论

留言簿(3)

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔分类

  • class(1) (rss)
  • false (rss)
  • interface (rss)
  • new (rss)
  • null(1) (rss)
  • package(1) (rss)
  • private(2) (rss)
  • protected (rss)
  • public(2) (rss)
  • true (rss)

随笔档案

  • 2007年9月 (1)
  • 2006年4月 (1)
  • 2006年3月 (3)
  • 2006年2月 (1)
  • 2005年12月 (1)

文章分类

  • misc(2) (rss)
  • ruby(1) (rss)
  • spring(4) (rss)
  • web service(1) (rss)

文章档案

  • 2006年5月 (1)
  • 2006年4月 (1)
  • 2006年3月 (6)

友情链接

  • 一再沈醉 (rss)

搜索

  •  

最新评论

  • 1. re: 如何应对xss攻击?
  • <script>aaa</script>
  • --wd
  • 2. re: Hello,World
  • <script>alert('testAAAAAAAAAAAAAAAAAA')</script>
  • --asas
  • 3. re: Hello,World
  • </script><script>alert('testAAAAAAAAAAAAAAAAAA');</script>
  • --asas
  • 4. re: Hello,World[未登录]
  • <script>alert('test')</script>
  • --haha
  • 5. re: Hello,World
  • <script>alert('test')</script>
  • --cxzvcx

阅读排行榜

  • 1. 如何应对xss攻击?(3976)
  • 2. 用jarkata的commons-VFS监视文件夹的变化(2370)
  • 3. webwork2.2.2里面的富文本编辑器存在的一些问题(1870)
  • 4. 一种新的hibernate和spring结合方式(1847)
  • 5. 写的一个简单的代码生成器(1835)

评论排行榜

  • 1. 如何应对xss攻击?(7)
  • 2. Hello,World(7)
  • 3. 用jarkata的commons-VFS监视文件夹的变化(6)
  • 4. 写的一个简单的代码生成器(4)
  • 5. 一种新的hibernate和spring结合方式(1)

Powered by: 博客园
模板提供:沪江博客
BlogJava | 首页 | 发新随笔 | 发新文章 | 联系 | 聚合 | 管理

我的评论

re: Spring AOP on Annotation[未登录] quaff 2011-06-07 16:24  
用spring aop有个限制就是被aop拦截的方法被this对象的另一个方法调用会绕过aop
re: Struts2-疑难杂症之Validator返回input视图 quaff 2010-06-10 08:50  
@Aidan
这是我提交给xwork的,看你的需求就知道这个功能就是为这个打造的
re: Struts2-疑难杂症之Validator返回input视图 quaff 2010-06-09 08:17  
请使用@InputConfig

public class DownloadController extends ActionSupport {

@InputConfig(methodName="inputIndex")
//@InputConfig(resultName="input")
public String index() {
System.out.println("-------index-----------");
return "xx";
}

public void validateIndex() {
addFieldError("hell", ".my hello.");
System.out.println("ok");
}

public string inputIndex() {
return "input";
}
}
re: XA分布式事务处理[未登录] quaff 2009-08-24 16:30  
当然可以,只要异构数据库也支持xa接口
re: 如何应对xss攻击? quaff 2007-09-24 17:18  
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.Perl5Substitution;
import org.apache.oro.text.regex.Util;

public class AntiXSS {
static final Pattern SCRIPT_TAG_PATTERN = Pattern.compile(
"<script[^>]*>.*</script[^>]*>", Pattern.CASE_INSENSITIVE);

static final PatternCompiler pc = new Perl5Compiler();
static final PatternMatcher matcher = new Perl5Matcher();

// http://www.bitscn.com/hack/young/200708/108278.html
public static String antiXSS(String content) {
String old = content;
String ret = _antiXSS(content);
while (!ret.equals(old)) {
old = ret;
ret = _antiXSS(ret);
}
return ret;
}

private static String _antiXSS(String content) {
try {
return stripAllowScriptAccess(stripProtocol(stripCssExpression(stripAsciiAndHex(stripEvent(stripScriptTag(content))))));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}

private static String stripScriptTag(String content) {
Matcher m = SCRIPT_TAG_PATTERN.matcher(content);
content = m.replaceAll("");
return content;
}

private static String stripEvent(String content) throws Exception {
String[] events = { "onmouseover", "onmouseout", "onmousedown",
"onmouseup", "onmousemove", "onclick", "ondblclick",
"onkeypress", "onkeydown", "onkeyup", "ondragstart",
"onerrorupdate", "onhelp", "onreadystatechange", "onrowenter",
"onrowexit", "onselectstart", "onload", "onunload",
"onbeforeunload", "onblur", "onerror", "onfocus", "onresize",
"onscroll", "oncontextmenu" };
for (String event : events) {
org.apache.oro.text.regex.Pattern p = pc.compile("(<[^>]*)("
+ event + ")([^>]*>)", Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util.substitute(matcher, p, new Perl5Substitution(
"$1" + event.substring(2) + "$3"), content,
Util.SUBSTITUTE_ALL);

}
return content;
}

private static String stripAsciiAndHex(String content) throws Exception {
// filter &# \00xx
org.apache.oro.text.regex.Pattern p = pc.compile(
"(<[^>]*)(&#|\\\\00)([^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util
.substitute(matcher, p, new Perl5Substitution("$1$3"),
content, Util.SUBSTITUTE_ALL);
return content;
}

private static String stripCssExpression(String content) throws Exception {
org.apache.oro.text.regex.Pattern p = pc.compile(
"(<[^>]*style=.*)/\\*.*\\*/([^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util
.substitute(matcher, p, new Perl5Substitution("$1$2"),
content, Util.SUBSTITUTE_ALL);

p = pc
.compile(
"(<[^>]*style=[^>]+)(expression|javascript|vbscript|-moz-binding)([^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util
.substitute(matcher, p, new Perl5Substitution("$1$3"),
content, Util.SUBSTITUTE_ALL);

p = pc.compile("(<style[^>]*>.*)/\\*.*\\*/(.*</style[^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util
.substitute(matcher, p, new Perl5Substitution("$1$2"),
content, Util.SUBSTITUTE_ALL);

p = pc
.compile(
"(<style[^>]*>[^>]+)(expression|javascript|vbscript|-moz-binding)(.*</style[^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util
.substitute(matcher, p, new Perl5Substitution("$1$3"),
content, Util.SUBSTITUTE_ALL);
return content;
}

private static String stripProtocol(String content) throws Exception {
String[] protocols = { "javascript", "vbscript", "livescript",
"ms-its", "mhtml", "data", "firefoxurl", "mocha" };
for (String protocol : protocols) {
org.apache.oro.text.regex.Pattern p = pc.compile("(<[^>]*)"
+ protocol + ":([^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util.substitute(matcher, p, new Perl5Substitution(
"$1/$2"), content, Util.SUBSTITUTE_ALL);
}
return content;
}

private static String stripAllowScriptAccess(String content)
throws Exception {
org.apache.oro.text.regex.Pattern p = pc.compile(
"(<[^>]*)AllowScriptAccess([^>]*>)",
Perl5Compiler.CASE_INSENSITIVE_MASK);
if (null != p)
content = Util.substitute(matcher, p, new Perl5Substitution(
"$1Allow_Script_Access$2"), content, Util.SUBSTITUTE_ALL);
return content;
}

}
re: 如何应对xss攻击? quaff 2007-09-24 12:53  
BeanSoft

css的expression没有过滤,ie下面可以运行
<img lowsrc="javascript:alert('XSS')"/>这个在ie下面可以自动运行,还有链接里面使用javascript:xxx等其他协议比如firefoxurl:xxx

re: 随机数字验证码的生成[未登录] quaff 2007-09-22 09:26  
thanks
re: 一种新的hibernate和spring结合方式[未登录] quaff 2007-03-21 11:59  
对于new出来的domain object可以用spring和aspectj-weaver来注入依赖对象
re: 发布OSGI Opendoc正式版 quaff 2006-09-02 08:12  
UserValidatorWebBundle
org.riawork.demo.web.Activator
ServiceReference ref應該作為一個局部變量,因為org.eclipse.equinox.http停止然後重新開始會造成NPE
ref指向的還是原來的HttpService,下面得到的http為null
HttpService http = (HttpService) bc.getService(ref);
另外監聽HttpService的unregistering事件然後調用unregisterServlet方法沒必要,此時HttpService已經unregistered,取不到他的引用,沒法unregister Servlet,resources,我猜HttpService unregister的時候會自動unregister上面的servlet,resources


另外有個問題,黨註冊多個Service到一個名字的時候,根據這個名字取得Service的優先級是根據Bundle的名字排序,如何自己定制規則
re: 单例模式(SingLeton Pattern)的误区 quaff 2006-07-15 12:03  
@mixlee
两个application的classpath不一样,放在WEB-INF里面的lib是不能共享的,spring的ApplicationContext是跟具体的webapp相关的,当然不能做成全局的单例,只能做成一个ServletContext里面的单例
re: JBoss Rules 学习(七): Drools规则语言详解(下) quaff 2006-06-10 01:22  
一直在关注这个系列的文章,谢谢楼主