473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Conversion problem in parse_multipart

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
2 2258
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
2
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
14
by: Richard G. Riley | last post by:
Would it be wrong to use "implicit casting" instead of the standards "implicit conversion" when talking about implicit conversions between certain data types. The standard mentions "explicit...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.