For example, we pick random website from who uses webpy page who also
uses analytics and add non latin tracking params:
http://frinki.com/?utm_source=feedburner&utm_medium=twitter&utm_campaign=Feed:%20gradoskop%20%28Градоскоп%29&utm_content=Twitter

If you visit this link in Firefox (even Firefox 4), then analytics
will set up incorrect __utmz cookie in unicode, and the second and
further refreshes will show server error.

I fixed the problem by removing this buggy cookie in custom
internalerror (it tries to do so only one time to prevent redirect
loop):

def myinternalerror():
    try:
        web.cookies()
    except CookieError:
        if not "cookie_err" in web.input():
            web.setcookie("__utmz", None, domain=web.ctx.host)
            raise web.seeother(web.changequery(cookie_err=1))
    return web.internalerror(render.site.e500())

Who's problem is it:

1. google analytics setting incorrect cookie
2. firefox letting javascript set incorrect cookie and thus sending
incorrect request
3. webpy



On Mar 23, 12:09 am, andrei <[email protected]> wrote:
> Hi, my web app fails with incorrect cookie set by google analytics
> javascript.
> My question is how I can capture this exception, and issue redirect back
> clearing the buggy cookie?
>
> Here is traceback:
>
>   File "/home/dw0rm/lib/python2.6/web/application.py", line 282, in wsgi
>     result = self.handle_with_processors()
>   File "/home/dw0rm/lib/python2.6/web/application.py", line 252, in
> handle_with_processors
>     return process(self.processors)
>   File "/home/dw0rm/lib/python2.6/web/application.py", line 249, in process
>     raise self.internalerror()
>   File "/home/dw0rm/lib/python2.6/web/application.py", line 473, in
> internalerror
>     return debugerror.debugerror()
>   File "/home/dw0rm/lib/python2.6/web/debugerror.py", line 305, in
> debugerror
>     return web._InternalError(djangoerror())
>   File "/home/dw0rm/lib/python2.6/web/debugerror.py", line 295, in
> djangoerror
>     return t(exception_type, exception_value, frames)
>   File "/home/dw0rm/lib/python2.6/web/template.py", line 879, in __call__
>     return BaseTemplate.__call__(self, *a, **kw)
>   File "/home/dw0rm/lib/python2.6/web/template.py", line 806, in __call__
>     return self.t(*a, **kw)
>   File "/home/dw0rm/lib/python2.6/web/debugerror.pyo", line 196, in
> __template__
>
>   File "/home/dw0rm/lib/python2.6/web/webapi.py", line 316, in cookies
>     cookie.load(ctx.env.get('HTTP_COOKIE', ''))
>   File "/usr/local/lib/python2.6/Cookie.py", line 625, in load
>     self.__ParseString(rawdata)
>   File "/usr/local/lib/python2.6/Cookie.py", line 658, in __ParseString
>     self.__set(K, rval, cval)
>   File "/usr/local/lib/python2.6/Cookie.py", line 578, in __set
>     M.set(key, real_value, coded_value)
>   File "/usr/local/lib/python2.6/Cookie.py", line 455, in set
>     raise CookieError("Illegal key value: %s" % key)
> CookieError: Illegal key value: )|utmcmd

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to