skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Monday, October 22, 2012

Preventing CRLF injection

Posted by Raju Gupta at 5:30 AM – 0 comments
 
This code will encode your data if a user tries to attack your application through CRLF injection

String s=Arrays.toString(object);
if(s.contains("/") || s.contains(">")||s.contains("<")||s.contains("?") ||s.contains("&") ||s.contains(""))
{
 String validobject=URLEncoder.encode(s);
 System.out.println("the encoded data is"+validobject);
}
else
{
 System.out.println("the non-encoded data is"+object);
}


Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger