Re: Can this be rewritten better?



Joe Smith wrote:
Henry Law wrote:

if( param('select') and param('select') !~ /\.\./ )


I don't know what this is doing but it looks odd to me.  I can't
imagine what the two calls to "param" are returning which when anded
together could ever look like ".."


They're not anded together.  To perform an AND operation on two
integers require using & not && or 'and'.  The quoted line translates
to "if param('select') is true (not undef, not '', not 0, not '0')
and the value does not contain two consecutive periods ...".

It probably makes more sense to write it as
  if (defined param('select') and param('select') ~= /\.\./) { ... }

-Joe

I wrote it like this to avoid getting hackers pass cgi parameters to open files from the adress bar like:


http://www.nikolas.tk/cgi-bin/index.pl?select='../../somepath/somefile') :-)

--
I knew UNIX before it was spelled   L I N U X
        and
I knew INTERNET before it was spelled  W W W
.



Relevant Pages

  • Re: "what to do with Eric Gill"
    ... odd that someone should claim to have no take on topics such as this ... If you can't imagine someone's thought processes being different from ... newsgroup. ... If you think I'm lying why don't you come out and say so? ...
    (uk.religion.christian)
  • Re: Communal Dining?
    ... A few years ago, I went to a nudist B&B in Las Vegas, just imagine ... how odd that situation was. ... LOL! ...
    (rec.food.cooking)
  • Re: FFS ATTACK!
    ... Imagine doing this from the get go. ... We would sweep aside these teams easily by half-time. ... Sure, we might lose an odd one, but we would win the majority of those draws and the scum would be nowhere near us. ...
    (uk.sport.football.clubs.liverpool)
  • Re: "what to do with Eric Gill"
    ... odd that someone should claim to have no take on topics such as this. ... If you can't imagine someone's thought processes being different from ... Which of the seven heavens / Was responsible her smile / ... Wouldn't be sure but attested / That, whoever it was, a god / ...
    (uk.religion.christian)
  • Re: OT: P.C. terminology
    ... Mark Cooper wrote: ... there's no connotation of being a lower class citizen. ... That part is odd indeed. ... What I _could_ imagine is that for some ...
    (rec.collecting.coins)