Re: [Tutor] Untainting CGI parameters

2005-08-11 Thread Alan G
>>> type = re.search('\d+',a).group() or 'page' Traceback (most recent call last): File "", line 1, in ? AttributeError: 'NoneType' object has no attribute 'group' > If the search does not succeed, the returned object has the value > None, which has no attribute group. Ah yes! I forgot about t

Re: [Tutor] Untainting CGI parameters

2005-08-11 Thread Jan Eden
Hi Alan, Alan G wrote on 11.08.2005: >> I will combine Kent's and your suggestion, because he included a >> check for an AttributeError: >> > >OK, as a slightly more perl-ish solution to the no Attribute problem >you could also do this: > >try: >type = re.search('\w+', parameters['type'].val

Re: [Tutor] Untainting CGI parameters

2005-08-11 Thread Alan G
> I will combine Kent's and your suggestion, because he included a > check for an AttributeError: > OK, as a slightly more perl-ish solution to the no Attribute problem you could also do this: try: type = re.search('\w+', parameters['type'].value).group() or 'page' except KeyError: type

Re: [Tutor] Untainting CGI parameters

2005-08-11 Thread Jan Eden
Hi Kent, hi Alan, Kent Johnson wrote on 10.08.2005: >OK, I don't know much Perl but I don't think these two snippets do >the same thing. For one thing the regexes are different, second in >the Python you need to check if the match succeeds. > >>my $type = ($parameters{type} && ($parameters{type}

Re: [Tutor] Untainting CGI parameters

2005-08-10 Thread Alan G
> I would like to untaint all parameters with which my CGI script is > called. Example: Can you explain 'untaint'??? Not a term I'm familiar with... > if parameters.has_key('type'): > match = re.search('\w+', parameters['type'].value) > type = match.group() > else: type = 'page' I Pytho

Re: [Tutor] Untainting CGI parameters

2005-08-10 Thread Kent Johnson
Jan Eden wrote: > Hi, > > I would like to untaint all parameters with which my CGI script is called. > Example: > > if parameters.has_key('type'): > match = re.search('\w+', parameters['type'].value) > type = match.group() > else: type = 'page' OK, I don't know much Perl but I don't thi

[Tutor] Untainting CGI parameters

2005-08-10 Thread Jan Eden
Hi, I would like to untaint all parameters with which my CGI script is called. Example: if parameters.has_key('type'): match = re.search('\w+', parameters['type'].value) type = match.group() else: type = 'page' In Perl, I used the ternary operator to write it like this: my $type = ($pa