On Mon, 2006-19-06 at 11:01 +0200, Adam Groszer wrote: > Hi Marius, > > Your fix of browser.py causes problems for me using hurry.file when > running functional test with zope.testbrowser. > The problem is that aFieldStorage.filename is already unicode and it > cannot be decoded again. > > Do you mind if I add an > if isinstance(aFieldStorage.filename, unicode): > construct?
I don't mind, but I think it would be better if testbrowser was changed to match what real browsers do instead. On Mon, Jun 19, 2006 at 08:37:03AM -0230, Rocky Burt wrote: > Hmm, this seems strange to me. How can it be guaranteed that the remote > filename is a utf-8 encoded byte string? Not sure this should be done > this way anyhow. There's an RFC (1867) that says each part in a multipart/form-data request has headers ("filename" is one of them) that are always 7-bit ASCII and use MIME quoting (RFC 1522, "=?charset?encoding?encoded-text?=") if they need to represent non-ASCII characters. Experiments with two real-life browsers (Firefox on Linux, with a UTF-8 system locale, and MSIE 6 on Windows XP with Lithuanian regional settings, which, I presume, mean cp1257) showed that if I upload a filename with non-ASCII characters, I get a UTF-8 encoded str at this point in the code. I assumed that the cgi module from the standard library (that's where the aFieldStorage object comes from) takes care of charset conversions (but didn't actually check that assumption). Modified: Zope3/trunk/src/zope/publisher/browser.py =================================================================== --- Zope3/trunk/src/zope/publisher/browser.py2006-06-13 22:00:47 UTC (rev 68625) +++ Zope3/trunk/src/zope/publisher/browser.py2006-06-14 12:25:49 UTC (rev 68626) @@ -596,7 +596,7 @@ d[m] = getattr(file,m) self.headers = aFieldStorage.headers - self.filename = aFieldStorage.filename + self.filename = unicode(aFieldStorage.filename, 'UTF-8') class RedirectingBrowserRequest(BrowserRequest): """Browser requests that redirect when the actual and effective URLs differ Marius Gedminas -- We have enough youth, how about a fountain of SMART?
Description: Digital signature
_______________________________________________ Zope3-dev mailing list Zope3email@example.com Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com