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.

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  /**
   3   * Copyright 2012-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 2012-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Imap_Client
  12   */
  13  
  14  /**
  15   * Stream filter to output a quoted IMAP string.
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2012-2017 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Imap_Client
  22   */
  23  class Horde_Imap_Client_Data_Format_Filter_Quote extends php_user_filter
  24  {
  25      /**
  26       * Has the initial quote been prepended?
  27       *
  28       * @var boolean
  29       */
  30      protected $_prepend;
  31  
  32      /**
  33       */
  34      public function onCreate()
  35      {
  36          $this->_prepend = false;
  37      }
  38  
  39      /**
  40       * @see stream_filter_register()
  41       */
  42      public function filter($in, $out, &$consumed, $closing)
  43      {
  44          if (!$this->_prepend) {
  45              stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
  46              $this->_prepend = true;
  47          }
  48  
  49          while ($bucket = stream_bucket_make_writeable($in)) {
  50              $consumed += $bucket->datalen;
  51              $bucket->data = addcslashes($bucket->data, '"\\');
  52              stream_bucket_append($out, $bucket);
  53          }
  54  
  55          /* feof() call needed due to:
  56           * http://news.php.net/php.internals/80363 */
  57          if ($closing || feof($this->stream)) {
  58              stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
  59          }
  60  
  61          return PSFS_PASS_ON;
  62      }
  63  
  64  }