Ignore:
Timestamp:
Aug 8, 2019 10:03:59 PM (5 years ago)
Author:
anonymous
Message:

Add unicode flag (/u) to preg_* patterns. Remove usage of create_function().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Email.inc.php

    r684 r696  
    118118        . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)'                               // TRUE, ensure ending >
    119119        . '|'
    120         . '(?:|\s*|\s+\([^,@]+\)\s*))$/i'));                            // FALSE ensure there is no ending >
     120        . '(?:|\s*|\s+\([^,@]+\)\s*))$/iu'));                            // FALSE ensure there is no ending >
    121121
    122122        if (isset($params)) {
     
    260260        // Apply regex pattern to search elements.
    261261        $search = array_keys($replacements);
    262         array_walk($search, create_function('&$v', '$v = "{" . mb_strtoupper($v) . "}";'));
     262        array_walk($search, function (&$v) {
     263            $v = '{' . mb_strtoupper($v) . '}';
     264        });
    263265
    264266        // Replacement values.
     
    274276    * You can also use this function to do post-processing on the email body before sending it,
    275277    * like removing extraneous lines:
    276     * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n\n", $email->getBody()));
     278    * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/su', "\n\n", $email->getBody()));
    277279    *
    278280    * @access   public
     
    367369        foreach ($headers as $key => $val) {
    368370            // Validate key and values.
    369             if (empty($val)) {
     371            if (!strlen($val)) {
    370372                $app->logMsg(sprintf('Empty email header provided: %s', $key), LOG_NOTICE, __FILE__, __LINE__);
    371373                continue;
    372374            }
    373             if (empty($key) || !is_string($key) || !is_string($val) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) {
     375            if (!strlen($key) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) {
    374376                $app->logMsg(sprintf('Broken email header provided: %s=%s', $key, $val), LOG_WARNING, __FILE__, __LINE__);
    375377                continue;
     
    394396            $envelope_sender_address = sprintf('<%s>', trim($this->_params['envelope_sender_address'], '<>'));
    395397        } else {
    396             $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU', '$1', $this->_params['from']);
     398            $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iUu', '$1', $this->_params['from']);
    397399        }
    398400        if ('' != $envelope_sender_address && $this->validEmail($envelope_sender_address)) {
Note: See TracChangeset for help on using the changeset viewer.