Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   3  /**

   4   * Primitive email validation class based on the regexp found at

   5   * http://www.regular-expressions.info/email.html

   6   */
   7  class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_URI_Email
   8  {
   9  
  10      /**

  11       * @param string $string

  12       * @param HTMLPurifier_Config $config

  13       * @param HTMLPurifier_Context $context

  14       * @return bool|string

  15       */
  16      public function validate($string, $config, $context)
  17      {
  18          // no support for named mailboxes i.e. "Bob <bob@example.com>"

  19          // that needs more percent encoding to be done

  20          if ($string == '') {
  21              return false;
  22          }
  23          $string = trim($string);
  24          $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string);
  25          return $result ? $string : false;
  26      }
  27  }
  28  
  29  // vim: et sw=4 sts=4