struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschach...@apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/upload BufferedMultipartInputStream.java MultipartIterator.java
Date Mon, 02 Jul 2001 20:14:20 GMT
mschachter    01/07/02 13:14:19

  Modified:    src/share/org/apache/struts/upload Tag: STRUTS_1_0_BRANCH
                        BufferedMultipartInputStream.java
                        MultipartIterator.java
  Log:
   - fix for file corruption problem with uploads
  
  Submitted by:	Mason Blackwood
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +5 -1      jakarta-struts/src/share/org/apache/struts/upload/BufferedMultipartInputStream.java
  
  Index: BufferedMultipartInputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/BufferedMultipartInputStream.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- BufferedMultipartInputStream.java	2001/04/18 14:21:18	1.3
  +++ BufferedMultipartInputStream.java	2001/07/02 20:14:16	1.3.2.1
  @@ -204,7 +204,11 @@
               b[offset] = (byte) read;
               count++;
               offset++;
  -            read = read();
  +            //make sure that we don't ignore the last character if a
  +            //newline isn't encountered
  +            if (count < length) {
  +                read = read();
  +            }
           }
           return count;
       }
  
  
  
  1.13.2.2  +11 -6     jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java
  
  Index: MultipartIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java,v
  retrieving revision 1.13.2.1
  retrieving revision 1.13.2.2
  diff -u -r1.13.2.1 -r1.13.2.2
  --- MultipartIterator.java	2001/06/14 01:11:28	1.13.2.1
  +++ MultipartIterator.java	2001/07/02 20:14:17	1.13.2.2
  @@ -493,19 +493,25 @@
   
                           if (cutCarriage) {
                               fos.write('\r');
  +                            cutCarriage = false;
                           }
                           if (cutNewline) {
                               fos.write('\n');
  +                            cutNewline = false;
                           }
  -                        cutCarriage = false;
                           if (bytesRead > 0) {
                               if (lineBuffer[bytesRead-1] == '\r') {
  -                                bytesRead--;
  +                                //bytesRead--;
                                   cutCarriage = true;
  +                                fos.write(lineBuffer, 0, bytesRead-1);                
               
                               }
  +                            else {
  +                                fos.write(lineBuffer, 0, bytesRead);
  +                            }                               
                           }
  -                        cutNewline = true;
  -                        fos.write(lineBuffer, 0, bytesRead);
  +                        if (bytesRead < MAX_LINE_SIZE) {
  +                            cutNewline = true;
  +                        }
                           bytesRead = inputStream.readLine(lineBuffer, 0, MAX_LINE_SIZE);
               }
           }
  @@ -513,8 +519,7 @@
               fos.close();
               tempFile.delete();
               throw ioe;
  -        }
  -        
  +        }        
           fos.flush();	
           fos.close();
           return tempFile;
  
  
  

Mime
View raw message