473,769 Members | 7,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_multi part 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_multi part, 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 2284
Michele Belloli <mk*******@libe ro.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_mult ipart 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_multi part, 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*******@libe ro.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_mul tipart 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_multipar t'; 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_multi part, 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_mulit part shows the problem.
What operating system and what web server?


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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5655
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 at the bottom. Hope you can help me understand the "explicit" keyword and its usage. Specifically, Is "explicit" keyword only associated with constructor in C++? What's "implied conversion of types"?
7
3260
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 I couldn't find the exact rule in the C++ standard. And what if the classes have template parameters? It would be great if somebody could get me a rough hint where in the
16
5138
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. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
31
6649
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 variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
11
7622
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 Test. I expected the same error from the following line, but it compiles fine. The double is silently truncated to an int and then fed in to the implicit conversion operator. Why does this happen? Is there any way that I can keep the implicit...
2
6870
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 static explicit System.IntPtr (long);
3
4458
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 calling the constructor 'MyString::MyString(const wchar_t *)' c:\SrNet\jury\JuryTest.h(21) : see declaration of 'MyString::MyString' The class "StringData" uses a, whatever you call it, operator const
14
2228
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 conversion" for a cast operation
0
2292
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 pages to a variety of formats. SII's service bureau has a reputation as being a least-cost provider that can offer a timely turnaround with 100% accuracy. Here are some of the formats SII has converted over the last 20 years:
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.