yup.readLine() - if a newline char was not found at the end of the chunk read, it would end up doing an extra read and not do anything with the read character. this combined with the fact that createLocalFile was adding a newline aFTER the readLine() meant that the character was being replaced with newline.anyway i know how to fix the readline() and createlocalfile() too but i just raised the 4096 limit for time being. i doubt this bug exists in the latest version of struts though. if still is, users beware!!!
-----Original Message----- From: news [mailto:[EMAIL PROTECTED] Behalf Of Laurie Harper Sent: Saturday, May 21, 2005 11:26 PM To: user@struts.apache.org Subject: Re: file upload struts - pdf corrupted Ugh, I found the same bug in the multipart parse we were using in my last job. The problem was that readLine() removed the end-of-line characters and they were added back somewhere else, if I recall correctly. If it got a full 4092 characters in one read, there was no way to know if it had read a partial line 4092 characters long or a full line of 4092 character plus newline. Where the newline was added back on, there was no check implemented or possible to deal with this boundary condition. I can't remember how I fixed it (this was four or five years back) but it seems like the simplest solution would be not to stip the newline in readLine(). That change may break assumptions and invariants that need to hold elsewhere, though... L. meyawn wrote: > i found out what the problem was..the problem that happens is that if a file > has a line more than 4096 then you can see a character missing and instead > of it you will find a newline char..happens with every file, not only > PDF....maybe this problem is not in later version of struts but sure is in > 1.0 final release...the problem is with > upload.MultipartIterator.createLocalFile() and also in > BufferedMultipartInputStream.readLine()...wont bore you with details, but a > cheap fix would be to do MultipartIterator.MAX_READ_SIZE to something more > than 4092. > > -----Original Message----- > From: Adam Hardy [mailto:[EMAIL PROTECTED] > Sent: Saturday, May 21, 2005 7:15 PM > To: Struts Users Mailing List > Subject: Re: file upload struts - pdf corrupted > > > On 20/05/05 10:33 Nandan wrote: > >>Hello, >>I am using struts 1.0.2 to upload files. However sometimes a PDF file gets > > corrupted after a file upload. I see that random characters are replaced a > hex 0A. Is this is a known bug? Please let me know > >>GP > > > Try checking bugzilla for commons-fileupload, or ask on the > jakarta-commons user list. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]