Re[2]: [Zope3-dev] Re: SVN: Zope3/branches/3.3/ Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.
Hello Benji, Marius, Sorry, "entwarnung" It is hurry.file causing the the problem, it is doing def _toFormValue(self, value): if value == self.context.missing_value: return self._missing return FileUpload(FakeFieldStorage(value.filename, value.data)) and this FileUpload is trying to do the unicode translation again, that is causing my problems. If I do a return FileUpload(FakeFieldStorage(value.filename.encode('utf-8'), value.data)) my ftests pass again. Monday, June 19, 2006, 7:21:11 PM, you wrote: BY> Marius Gedminas wrote: >> I don't mind, but I think it would be better if testbrowser was changed >> to match what real browsers do instead. BY> +1 BY> However, we'd have to decide who is creating the unicode string: BY> testbrowser, mechanize, or the publishing framework. -- Best regards, Groszer Adam -- Quote of the day: Justice is truth in action. - Joseph Joubert ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Re: SVN: Zope3/branches/3.3/ Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.
Marius Gedminas wrote: I don't mind, but I think it would be better if testbrowser was changed to match what real browsers do instead. +1 However, we'd have to decide who is creating the unicode string: testbrowser, mechanize, or the publishing framework. -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Re: SVN: Zope3/branches/3.3/ Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.
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? signature.asc Description: Digital signature ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] Re: SVN: Zope3/branches/3.3/ Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.
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. - Rocky 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? > > 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 > -- Rocky Burt ServerZen Software -- http://www.serverzen.com News About The Server (blog) -- http://www.serverzen.net signature.asc Description: This is a digitally signed message part ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com