Opened 16 years ago

Closed 15 years ago

#1979 defect closed fixed (fixed)

FileSaver replaces LF with CRLF

Reported by: agreif Owned by: dialtone
Priority: high Milestone: Web2-Gold-Master
Component: web2 Keywords:
Cc: alex.greif@…, Cory Dodt, jknight Branch:
Author:

Description

On windows XP (python 2.4.2) the latest svn checkout produces the following bug: FileSaver converts LF to CRLF automatically, even in binary files!!

I tried to upload files with the following code:

child_uploadfile = static.FileSaver(destination='d:/agreif/tmp',

expectedFields=filename?, maxBytes=10000000,

allowedTypes=[http_headers.MimeType('text', 'x-python'),

http_headers.MimeType('application','x-zip-compressed')])

here is the hexdump of two samples. You see that in front of every occurrance of "0A" a "0D" is inserted.

Sample 1: textfile orig: 68616C6C6F0A uploaded: 68616C6C6F0D0A

Sample 2 binary file (zip) orig: 504B03040A00000000001589FF34D13172B90500000005000000100000004E6575205465787464617465692E707968616C6C6F504B010214000A00000000001589FF34D13172B905000000050000001000000000000000010020000000000000004E6575205465787464617465692E7079504B050600000000010001003E000000330000000000 uploaded: 504B03040D0A00000000001589FF34D13172B90500000005000000100000004E6575205465787464617465692E707968616C6C6F504B010214000D0A00000000001589FF34D13172B905000000050000001000000000000000010020000000000000004E6575205465787464617465692E7079504B050600000000010001003E000000330000000000

Attachments (1)

1979_test.txt (829 bytes) - added by Cory Dodt 16 years ago.
Failing test in test_static to expose this problem

Download all attachments as: .zip

Change History (10)

comment:1 Changed 16 years ago by agreif

Cc: alex.greif@… added

Changed 16 years ago by Cory Dodt

Attachment: 1979_test.txt added

Failing test in test_static to expose this problem

comment:2 Changed 16 years ago by Cory Dodt

Cc: Cory Dodt jknight added

comment:3 Changed 16 years ago by Cory Dodt

I thought this would be a simple matter of changing 'w' to 'wb' in static.py, but when I made that change the test still fails, so the stream is producing bad data.

comment:4 Changed 16 years ago by Glyph

Milestone: Web2-Gold-Master

Since file uploads are such a major new feature of web2 (ostensibly the reason for its existence) I'd say that this is important to its taking over from web...

comment:5 Changed 15 years ago by therve

This problem seems to exist under windows only.

comment:6 Changed 15 years ago by dialtone

Keywords: review added

I think I fixed this bug in filesaver-1979 branch. It's now ready for review.

comment:7 Changed 15 years ago by dialtone

small changes but still set for review

comment:8 Changed 15 years ago by jknight

Keywords: review removed
Owner: changed from jknight to dialtone

Looks fine on windows now; I noticed that docstring for writeFile mentions the nonexistent isWriteable instead of isSafeToWrite.

comment:9 Changed 15 years ago by dialtone

Resolution: fixed
Status: newclosed

(In [20546]) static.FileSaver() doesn't add '\r\n' when run on windows anymore.

Author: dialtone

Reviewer: foom

Fixes #1979

Note: See TracTickets for help on using tickets.