Hi there,

We've discovered what appears to be a bug in TurboGears that makes it
so we are unable to serve files over a certain size to Safari users.
This will affect anyone who is using cherrypy serveFile on the server
and a Safari client.  The user will see a 500 error, and the download
won't work.

We are using cherrypy.lib.cptools.serveFile to allow users to download
vcard and csv files.  If the file being served is larger than a certain
size, serveFile returns a Generator rather than a string.  The problem
occurs in the TurboGears controllers.py, in  _process_output.   When
TurboGears attempts to fix a Safari XML HttpRequest encoding problem,
the following code causes a 500 error:

if ua.browser == "safari":
    if isinstance(output, str):
        output = output.decode(enc)
    output = unicodechars.sub(lambda m: "&#x%x;" % ord(m.group(1)),
output).encode("ascii")

unicodechars.sub does not support a Generator as the second argument.
Since the output variable is a Generator, the execution of this last
line gives us:  "TypeError: expected string or buffer"

This could be a problem for anyone who is serving files to Safari
users.  They will be hit with an ugly 500 error.

I've created a ticket for this on the TurboGears Trac:
http://trac.turbogears.org/turbogears/ticket/1125

Naomi


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to