Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for Metafox/lib/Mail/RFC822.php between version 1.4 and 1.5

version 1.4, 2006/03/29 09:23:13 version 1.5, 2011/06/17 13:56:39
Line 1 
Line 1 
 <?php  <?php
 // +-----------------------------------------------------------------------+  /**
 // | Copyright (c) 2001-2002, Richard Heyes                                |   * RFC 822 Email address list validation Utility
 // | All rights reserved.                                                  |   *
 // |                                                                       |   * PHP versions 4 and 5
 // | Redistribution and use in source and binary forms, with or without    |   *
 // | modification, are permitted provided that the following conditions    |   * LICENSE:
 // | are met:                                                              |   *
 // |                                                                       |   * Copyright (c) 2001-2010, Richard Heyes
 // | o Redistributions of source code must retain the above copyright      |   * All rights reserved.
 // |   notice, this list of conditions and the following disclaimer.       |   *
 // | o Redistributions in binary form must reproduce the above copyright   |   * Redistribution and use in source and binary forms, with or without
 // |   notice, this list of conditions and the following disclaimer in the |   * modification, are permitted provided that the following conditions
 // |   documentation and/or other materials provided with the distribution.|   * are met:
 // | o The names of the authors may not be used to endorse or promote      |   *
 // |   products derived from this software without specific prior written  |   * o Redistributions of source code must retain the above copyright
 // |   permission.                                                         |   *   notice, this list of conditions and the following disclaimer.
 // |                                                                       |   * o Redistributions in binary form must reproduce the above copyright
 // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |   *   notice, this list of conditions and the following disclaimer in the
 // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |   *   documentation and/or other materials provided with the distribution.
 // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |   * o The names of the authors may not be used to endorse or promote
 // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |   *   products derived from this software without specific prior written
 // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |   *   permission.
 // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |   *
 // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // |                                                                       |   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // +-----------------------------------------------------------------------+   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // | Authors: Richard Heyes <richard@phpguru.org>                          |   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // |          Chuck Hagenbuch <chuck@horde.org>                            |   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // +-----------------------------------------------------------------------+   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    * @category    Mail
    * @package     Mail
    * @author      Richard Heyes <richard@phpguru.org>
    * @author      Chuck Hagenbuch <chuck@horde.org
    * @copyright   2001-2010 Richard Heyes
    * @license     http://opensource.org/licenses/bsd-license.php New BSD License
    * @version     CVS: $Id$
    * @link        http://pear.php.net/package/Mail/
    */
   
 /**  /**
  * RFC 822 Email address list validation Utility   * RFC 822 Email address list validation Utility
Line 342  class Mail_RFC822 {
Line 353  class Mail_RFC822 {
     }      }
   
     /**      /**
      * Checks if a string has an unclosed quotes or not.       * Checks if a string has unclosed quotes or not.
      *       *
      * @access private       * @access private
      * @param string $string The string to check.       * @param string $string  The string to check.
      * @return boolean True if there are unclosed quotes inside the string, false otherwise.       * @return boolean  True if there are unclosed quotes inside the string,
        *                  false otherwise.
      */       */
     function _hasUnclosedQuotes($string)      function _hasUnclosedQuotes($string)
     {      {
         $string     = explode('"', $string);          $string = trim($string);
         $string_cnt = count($string);          $iMax = strlen($string);
           $in_quote = false;
           $i = $slashes = 0;
   
           for (; $i < $iMax; ++$i) {
               switch ($string[$i]) {
               case '\\':
                   ++$slashes;
                   break;
   
               case '"':
                   if ($slashes % 2 == 0) {
                       $in_quote = !$in_quote;
                   }
                   // Fall through to default action below.
   
         for ($i = 0; $i < (count($string) - 1); $i++)              default:
             if (substr($string[$i], -1) == '\\')                  $slashes = 0;
                 $string_cnt--;                  break;
               }
           }
   
         return ($string_cnt % 2 === 0);          return $in_quote;
     }      }
   
     /**      /**
Line 618  class Mail_RFC822 {
Line 646  class Mail_RFC822 {
                 $comment    = $this->_splitCheck($parts, ')');                  $comment    = $this->_splitCheck($parts, ')');
                 $comments[] = $comment;                  $comments[] = $comment;
   
                 // +1 is for the trailing )                  // +2 is for the brackets
                 $_mailbox   = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1);                  $_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment)+strlen($comment)+2);
             } else {              } else {
                 break;                  break;
             }              }
Line 912  class Mail_RFC822 {
Line 940  class Mail_RFC822 {
      */       */
     function isValidInetAddress($data, $strict = false)      function isValidInetAddress($data, $strict = false)
     {      {
         $regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';          $regex = $strict ? '/^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i';
         if (preg_match($regex, trim($data), $matches)) {          if (preg_match($regex, trim($data), $matches)) {
             return array($matches[1], $matches[2]);              return array($matches[1], $matches[2]);
         } else {          } else {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top