[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/captcha ...

Christian Bauer christian at hibernate.org
Wed Oct 10 03:09:27 EDT 2007


  User: cbauer  
  Date: 07/10/10 03:09:27

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/captcha 
                        WikiCaptcha.java
  Log:
  Defensive against invalid user input
  
  Revision  Changes    Path
  1.3       +9 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/captcha/WikiCaptcha.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiCaptcha.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/captcha/WikiCaptcha.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- WikiCaptcha.java	17 Aug 2007 13:00:31 -0000	1.2
  +++ WikiCaptcha.java	10 Oct 2007 07:09:27 -0000	1.3
  @@ -8,12 +8,14 @@
   
   import org.jboss.seam.Component;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.faces.FacesMessages;
   import org.jboss.seam.annotations.Create;
   import org.jboss.seam.annotations.Install;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
   
  +import javax.faces.application.FacesMessage;
   import java.io.Serializable;
   import java.security.SecureRandom;
   import java.util.Random;
  @@ -55,6 +57,13 @@
       }
   
       public boolean validateResponse(String response) {
  +        try {
  +            new Integer(response);
  +        } catch (NumberFormatException ex) {
  +            this.response = null;
  +            return false;
  +        }
  +
           if (new Integer(one + two).equals(new Integer(response))) {
               // TODO: Fuck that, doesn't clean out the old value.... no idea why
               this.response = null;
  
  
  



More information about the jboss-cvs-commits mailing list