Bug with URL encoding?

46 views
Skip to first unread message

Francisco Ribeiro

unread,
Oct 19, 2017, 1:30:09 PM10/19/17
to web2py-users
Hi,

I have found that when I do request.args(), colons ':' even when properly URL encoded become an underscore '_' .

def echo():
   
print request.args(0)
   
return dict()

A request http://.../echo/%a_ will become :
__ 

which prevents me from distinguishing one from another.

Am I missing something? shouldn't request.args() take care of URL encoding / decoding for me?

Thank you
Kind regards,
Francisco Ribeiro

Anthony

unread,
Oct 20, 2017, 11:32:49 AM10/20/17
to web2py-users
By default, characters in args that do not match the '[^\w/.@=-]' regular expression are replaced with underscores. To override that behavior, there are two options:
  1. In routes.py, set routes_apps_raw to a list of applications that will handle their own args parsing. In those apps, the entire args part of the URL (everything in path_info after /app/controller/function) will be available in request.raw_args, and you will have to parse it yourself.
  2. Use the parameter-based rewrite system and specify args_match to suit your needs (the default args_match regex is '([\w@ =-]|(?<=[\w@ -])[.])*$'.
Anthony

Francisco Ribeiro

unread,
Oct 22, 2017, 7:59:50 PM10/22/17
to web2py-users
Thank you!
Reply all
Reply to author
Forward
0 new messages