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:15:35 GMT
mschachter    01/07/02 13:15:35

  Modified:    src/share/org/apache/struts/upload
                        BufferedMultipartInputStream.java
                        MultipartIterator.java
  Log:
   - fix for file corruption problem with uploads (Main Branch)
  
  Submitted By: Mason Blackwood
  
  Revision  Changes    Path
  1.4       +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.4
  diff -u -r1.3 -r1.4
  --- BufferedMultipartInputStream.java	2001/04/18 14:21:18	1.3
  +++ BufferedMultipartInputStream.java	2001/07/02 20:15:33	1.4
  @@ -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.15      +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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MultipartIterator.java	2001/06/14 01:12:14	1.14
  +++ MultipartIterator.java	2001/07/02 20:15:34	1.15
  @@ -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