Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   1  <?php
   2  /**
   3   * Copyright 2014-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2014-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Object representation of an IMAP mailbox string allowed when UTF8=ACCEPT
  16   * is supported/enabled on the server (RFC 6855 [3]).
  17   *
  18   * @author    Michael Slusarz <slusarz@horde.org>
  19   * @category  Horde
  20   * @copyright 2014-2017 Horde LLC
  21   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  22   * @package   Imap_Client
  23   */
  24  class Horde_Imap_Client_Data_Format_Mailbox_Utf8
  25  extends Horde_Imap_Client_Data_Format_Mailbox
  26  implements Horde_Imap_Client_Data_Format_String_Support_Nonascii
  27  {
  28      /**
  29       */
  30      protected $_encoding = 'utf8';
  31  
  32      /**
  33       */
  34      public function __construct($data)
  35      {
  36          parent::__construct($data);
  37  
  38          /* RFC 3501 allows any US-ASCII character, except null (\0), in
  39           * mailbox data.
  40           * RFC 6855 [3] institutes additional limitations on valid mailbox
  41           * characters, to comply with RFC 5198 [2] (Net-Unicode Definition):
  42           * "MUST NOT contain control characters (U+0000-U+001F and
  43           * U+0080-U+009F), a delete character (U+007F), a line separator
  44           * (U+2028), or a paragraph separator (U+2029)." */
  45          if ($this->quoted() &&
  46              preg_match('/[\x00-\x1f\x7f\x80-\x9f\x{2028}\x{2029}]/u', strval($this))) {
  47              throw new Horde_Imap_Client_Data_Format_Exception(
  48                  'Invalid character found in mailbox data.'
  49              );
  50          }
  51  
  52          if ($this->literal()) {
  53              $this->forceQuoted();
  54          }
  55      }
  56  
  57  }