Conversion problem in parse_multipart

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michele Belloli

    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...

  • Tim Roberts

    #2
    Re: Conversion problem in parse_multipart

    Michele Belloli <mkbelloli@libe ro.it> wrote:[color=blue]
    >
    >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.[/color]

    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.
    [color=blue]
    >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.[/color]

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

    What operating system and what web server?
    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Michele Belloli

      #3
      Re: Conversion problem in parse_multipart

      On Wed, 01 Oct 2003 20:23:56 -0700, Tim Roberts <timr@probo.com >
      wrote:
      [color=blue]
      >Michele Belloli <mkbelloli@libe ro.it> wrote:[color=green]
      >>
      >>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.[/color]
      >
      >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.
      >[/color]

      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.
      [color=blue][color=green]
      >>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.[/color]
      >
      >How are you determining this? That is, how are you accessing the final
      >data?
      >[/color]

      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.
      [color=blue]
      >What operating system and what web server?[/color]

      W2K and python web server using SimpleHTTPServe r classes


      Thanks

      Comment

      Working...