By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,931 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

Conversion problem in parse_multipart

P: n/a
Hi folks...

I have a problem uploading a file to a web server.

I created an html page with a multipart/form-data form and used
cgi.parse_multipart function to obtain form data (and obviuosly
uploaded file).
I noticed that if I upload an excutable file, I obtain a file where
0x0a 0x0a, are converted in 0x0a and 0x2e.
Obviously this file is corrupted.

When I save the file, I use 'wb' flags to create a binary file...

Analyzing the file before cgi.parse_multipart, it's possible to
verify that it's correct but when this function tries to extract its
value, 0x0a 0x0a are converted in 0x0a and 02e.

Any suggestion?

Thanks a lot...

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Michele Belloli <mk*******@libero.it> wrote:

I have a problem uploading a file to a web server.

I created an html page with a multipart/form-data form and used
cgi.parse_multipart function to obtain form data (and obviuosly
uploaded file).
I noticed that if I upload an excutable file, I obtain a file where
0x0a 0x0a, are converted in 0x0a and 0x2e.
Obviously this file is corrupted.
Are you sure? We had something similar reported just a few weeks ago where
the bug turned out to be in the program displaying the hex results; the
binary file was just fine.

I have used cgi.py to handle large file uploads literally tens of thousands
of times, and never had one go bad.
Analyzing the file before cgi.parse_multipart, it's possible to
verify that it's correct but when this function tries to extract its
value, 0x0a 0x0a are converted in 0x0a and 02e.


How are you determining this? That is, how are you accessing the final
data?

What operating system and what web server?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #2

P: n/a
On Wed, 01 Oct 2003 20:23:56 -0700, Tim Roberts <ti**@probo.com>
wrote:
Michele Belloli <mk*******@libero.it> wrote:

I have a problem uploading a file to a web server.

I created an html page with a multipart/form-data form and used
cgi.parse_multipart function to obtain form data (and obviuosly
uploaded file).
I noticed that if I upload an excutable file, I obtain a file where
0x0a 0x0a, are converted in 0x0a and 0x2e.
Obviously this file is corrupted.
Are you sure? We had something similar reported just a few weeks ago where
the bug turned out to be in the program displaying the hex results; the
binary file was just fine

I have used cgi.py to handle large file uploads literally tens of thousands
of times, and never had one go bad.


I read cgi.py, in particular 'parse_multipart'; and I repeated each
command in a python shell.
It works fine.
I use the same version (2.2.3) in Python shell and web server but I
obtain two different behaviuors.
Analyzing the file before cgi.parse_multipart, it's possible to
verify that it's correct but when this function tries to extract its
value, 0x0a 0x0a are converted in 0x0a and 02e.


How are you determining this? That is, how are you accessing the final
data?


I noticed a bug displaying the hex results using 'print' statement
too, so I created a binary file (using 'wb' flags) and write down
results. Then, I read it using an hex-editor.
Reading file, I tought 'write' method could modify result like 'print'
statement do.
So I used a simple conditional statement.
if result =='\x2e':
file.write(.....)

Both test in cgi.parse_mulitpart shows the problem.
What operating system and what web server?


W2K and python web server using SimpleHTTPServer classes
Thanks
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.