On Monday, October 11, 2010 15:55:49 Remi Jolin wrote:
> Le 11/10/2010 15:35, Diez B. Roggisch a écrit :
> > On Monday, October 11, 2010 15:25:52 Remi Jolin wrote:
> >> Hello,
> >>
> >> I've just found a QR-Code reader that adds a variable to the encoded URL
> >> before passing it to the navigator and this variable is
> >> "mobiletag-title=http%3A%2F%2Fwww...etc....".
> >> The problem is that TG tries to decode that variable through
> >> formencode/variabledecode/variable_decode which is not pleased by the
> >> "-" ...
> >> What can I do to solve this issue ? Any suggestion ?
> >> (changing the QR-Code reader is not an option as the TG application is
> >> supposed to be used by anybody)
> >
> > I think your best option is to install a filter that alters the request
> > so that the attribute name "mobiletag-title" gets re-mapped to e.g.
> > mobiletag_title.
>
> Yes, but the issue is that I cannot predict what parameter name a new
> tool can invent... :-(
>
> I found another way to get it right :
> patch turbogears.filters.base.py to add a exeption handler to the filter.
>
> class NestedVariablesFilter(object):
> """Request filter that turns request params with names in special
> dotted
> notation into nested dictionaries via FormEncode's NestedVariables
> validator.
>
> """
> def before_main(self):
> if hasattr(request, 'params'):
> try:
> request.params =
> NestedVariables.to_python(request.params or {})
> except ValueError, e:
> log.warning(u'ValueError: %s' % e)
>
> So : if it can't decode nested variables, it lets the parameter as-is...
>
> What do you think about that ?
If it works... I think it's not really ok, because in the end, it can't be the
expectation of somebody who produces URLs for a web-application that it
expects all kinds of additional variables. I mean - what's the use of these in
the first place, if they are simply ignored?
So my approach would be to work around these properly. Either for known cases,
or by creating a filter for a specific path that cleans the request and only
leaves the known and accepted parameters.
Diez
--
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?hl=en.