Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Regex special question

Expand Messages
  • Jenda Krynicky
    From: drenzii ... Never search for dangerous characters! Always check they entered only the safe ones! Jenda ===== Jenda@Krynicky.cz ===
    Message 1 of 2 , Jul 23, 2004
    • 0 Attachment
      From: "drenzii" <drenzi@...>
      > Hello,
      > now I wrote a secure script to validate input field from a web form...
      > I start reading "Mastering Regular Expression" but I still not very
      > experienced with this stuff... So, what do you think about that?
      >
      > if ( $name =~ /[^A-Za-z.,; ]/ || length($name) > 50
      > || $email =~ /\\n|[;,<>*\/`()&\$\#\%]/ || length($email) > 50
      > || $subject =~ /\\n/ || length($subject) > 100
      > || $section =~ /\\n[;,<>*\/|&`()\$\#\%]/ || length($section) > 30 ||
      > $lng =~ /\\n[;,.<>*\/|&`()\$\#\%]/ || length($lng) > 2 || $site =~
      > /\\n[;,<>*|&`()\$\#\%]/ || length($site)> 100 || $id_site =~
      > /\\n[;,.<>*\/|&`()\$\#\%]/ || length($id_site) > 5 || length($message)
      > > 2000) {
      > show_unsuccessful_page();
      > }
      >
      > This code prevent to put special characters in the form fields and
      > also prevent spammers use the form to send spam.

      Never search for dangerous characters!
      Always check they entered only the safe ones!

      Jenda
      ===== Jenda@... === http://Jenda.Krynicky.cz =====
      When it comes to wine, women and song, wizards are allowed
      to get drunk and croon as much as they like.
      -- Terry Pratchett in Sourcery
    Your message has been successfully submitted and would be delivered to recipients shortly.