martinc     01/12/27 23:20:00

  Modified:    src/share/org/apache/struts/action Action.java
  Log:
  Fixed a bug in the toHex() method which caused leading zeros to be omitted
  from the string representation.
  
  Note that I do not plan on incorporating this fix into Struts 1.0.1. This
  method is currently used only to generate tokens which will be exactly
  matched. As such, accuracy is less important than uniqueness. The lack of
  accuracy should not constitute a showstopper for Struts 1.0.1.
  
  PR: 5458
  Submitted by: Marcelo Collao Huper
  
  Revision  Changes    Path
  1.29      +11 -6     jakarta-struts/src/share/org/apache/struts/action/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Action.java       2001/12/26 23:14:50     1.28
  +++ Action.java       2001/12/28 07:20:00     1.29
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.28 
2001/12/26 23:14:50 craigmcc Exp $
  - * $Revision: 1.28 $
  - * $Date: 2001/12/26 23:14:50 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.29 
2001/12/28 07:20:00 martinc Exp $
  + * $Revision: 1.29 $
  + * $Date: 2001/12/28 07:20:00 $
    *
    * ====================================================================
    *
  @@ -108,7 +108,7 @@
    * by this Action.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.28 $ $Date: 2001/12/26 23:14:50 $
  + * @version $Revision: 1.29 $ $Date: 2001/12/28 07:20:00 $
    */
   
   public class Action {
  @@ -608,8 +608,13 @@
       protected String toHex(byte buffer[]) {
   
           StringBuffer sb = new StringBuffer();
  -        for (int i = 0; i < buffer.length; i++)
  -            sb.append(Integer.toHexString((int) buffer[i] & 0xff));
  +        String s = null;
  +        for (int i = 0; i < buffer.length; i++) {
  +            s = Integer.toHexString((int) buffer[i] & 0xff);
  +            if (s.length() < 2)
  +                sb.append('0');
  +            sb.append(s);
  +        }
           return (sb.toString());
   
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to