├── .travis.ini ├── .travis.php7.ini ├── locale ├── da │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── de │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── el │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── es │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── eu │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── fi │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── fr │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── hu │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── ja │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo ├── nl │ └── LC_MESSAGES │ │ └── Horde_Imap_Client.mo └── tr │ └── LC_MESSAGES │ └── Horde_Imap_Client.mo ├── test └── Horde │ └── Imap │ └── Client │ ├── AllTests.php │ ├── bootstrap.php │ ├── fixtures │ ├── remote1.txt │ ├── remote5.txt │ ├── remote3.txt │ ├── remote2.txt │ └── clientsort2.txt │ ├── Data │ ├── Fetch │ │ ├── FetchTest.php │ │ └── FetchPop3Test.php │ ├── Format │ │ ├── String │ │ │ └── NonasciiTest.php │ │ ├── Astring │ │ │ └── NonasciiTest.php │ │ ├── Nstring │ │ │ └── NonasciiTest.php │ │ ├── TestBase.php │ │ ├── NilTest.php │ │ ├── DateTest.php │ │ ├── DateTimeTest.php │ │ ├── NumberTest.php │ │ ├── NstringTest.php │ │ ├── AstringTest.php │ │ ├── StringTest.php │ │ ├── Mailbox │ │ │ ├── MailboxUtf8Test.php │ │ │ ├── ListMailboxTest.php │ │ │ ├── ListMailboxUtf8Test.php │ │ │ └── TestBase.php │ │ ├── AtomTest.php │ │ └── ListTest.php │ ├── AclTest.php │ ├── SubjectParseTest.php │ ├── SearchCharsetUtf8Test.php │ └── SearchCharsetTest.php │ ├── Stub │ ├── Scram.php │ ├── Utf7imap.php │ ├── ClientSort.php │ ├── DigestMD5.php │ └── Socket.php │ ├── Fetch │ └── Results │ │ ├── FetchTest.php │ │ └── FetchPop3Test.php │ ├── Cache │ ├── CacheTest.php │ ├── HashtableTest.php │ ├── DbTest.php │ └── MongoTest.php │ ├── conf.php.dist │ ├── Live │ ├── Base.php │ ├── ImapTest.php │ ├── Pop3Test.php │ └── Pop3.php │ ├── Url │ ├── BaseTest.php │ ├── TestBase.php │ └── Pop3Test.php │ ├── Xoauth2Test.php │ ├── Ids │ └── Pop3Test.php │ ├── DateTimeTest.php │ ├── Utf7ConvertTest.php │ ├── Interaction │ └── CommandTest.php │ ├── Namespace │ └── ListTest.php │ └── AuthTest.php ├── phpunit.xml.dist ├── .gitignore ├── .travis.yml ├── lib └── Horde │ └── Imap │ └── Client │ ├── Data │ ├── Format │ │ ├── Exception.php │ │ ├── String │ │ │ ├── Support │ │ │ │ └── Nonascii.php │ │ │ └── Nonascii.php │ │ ├── Astring │ │ │ └── Nonascii.php │ │ ├── Nstring │ │ │ └── Nonascii.php │ │ ├── Astring.php │ │ ├── DateTime.php │ │ ├── ListMailbox.php │ │ ├── Nil.php │ │ ├── ListMailbox │ │ │ └── Utf8.php │ │ ├── Number.php │ │ ├── Date.php │ │ ├── Atom.php │ │ ├── Filter │ │ │ └── Quote.php │ │ ├── Mailbox │ │ │ └── Utf8.php │ │ ├── Nstring.php │ │ ├── Mailbox.php │ │ └── List.php │ ├── AclNegative.php │ ├── Fetch │ │ └── Pop3.php │ ├── SearchCharset │ │ └── Utf8.php │ ├── Format.php │ └── AclCommon.php │ ├── Interaction │ ├── Server │ │ ├── Untagged.php │ │ ├── Continuation.php │ │ └── Tagged.php │ ├── Client.php │ └── Command │ │ └── Continuation.php │ ├── Base │ ├── Password.php │ └── Alerts.php │ ├── Exception │ ├── Sync.php │ ├── NoSupportPop3.php │ ├── SearchCharset.php │ ├── NoSupportExtension.php │ └── ServerResponse.php │ ├── Translation.php │ ├── Url │ ├── Imap │ │ └── Relative.php │ └── Pop3.php │ ├── Cache │ └── Backend │ │ └── Null.php │ ├── Password │ └── Xoauth2.php │ ├── Ids │ └── Pop3.php │ ├── Socket │ └── Connection │ │ ├── Base.php │ │ └── Pop3.php │ └── Namespace │ └── List.php ├── .horde.yml ├── migration └── Horde │ └── Imap │ └── Client │ ├── 2_horde_imap_client_change_column_name.php │ └── 1_horde_imap_client_base_tables.php ├── composer.json └── .github └── workflows ├── release.yml ├── update-satis.yml ├── ci.yml └── phpdoc.yml /.travis.ini: -------------------------------------------------------------------------------- 1 | extension = mongo.so 2 | -------------------------------------------------------------------------------- /.travis.php7.ini: -------------------------------------------------------------------------------- 1 | extension = mongodb.so 2 | -------------------------------------------------------------------------------- /locale/da/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/da/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/de/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/de/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/el/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/el/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/es/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/es/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/eu/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/eu/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/fi/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/fi/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/fr/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/fr/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/hu/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/hu/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/ja/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/ja/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/nl/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/nl/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /locale/tr/LC_MESSAGES/Horde_Imap_Client.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/horde/Imap_Client/HEAD/locale/tr/LC_MESSAGES/Horde_Imap_Client.mo -------------------------------------------------------------------------------- /test/Horde/Imap/Client/AllTests.php: -------------------------------------------------------------------------------- 1 | run(); 6 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/bootstrap.php: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | test 6 | 7 | 8 | 9 | 10 | lib 11 | 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .buildpath 3 | .cache 4 | .project 5 | .settings 6 | .vscode 7 | nbproject/ 8 | *~ 9 | .#* 10 | *.bak 11 | *.orig 12 | *.rej 13 | *.swp 14 | *.kdev4 15 | .kdev4/* 16 | 17 | # Ignore ALL config files 18 | conf.php 19 | 20 | # Ignore testing files 21 | run-tests.log 22 | /test/*/*/*.diff 23 | /test/*/*/*.exp 24 | /test/*/*/*.log 25 | /test/*/*/*.out 26 | /test/*/*/*/*.diff 27 | /test/*/*/*/*.exp 28 | /test/*/*/*/*.log 29 | /test/*/*/*/*.out 30 | 31 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/fixtures/remote1.txt: -------------------------------------------------------------------------------- 1 | Return-Path: 2 | Delivered-To: foo@example.com 3 | Received: from test1.example.com (test1.example.com [192.168.10.10]) 4 | by test2.example.com (Postfix) with ESMTP id E6F7890AF 5 | for ; Sat, 26 Jul 2008 20:09:03 -0600 (MDT) 6 | Message-ID: 7 | Date: Sat, 26 Jul 2008 21:10:00 -0500 (CDT) 8 | From: Test 9 | To: foo@example.com 10 | Subject: Test e-mail 1 11 | Mime-Version: 1.0 12 | Content-Type: text/plain 13 | 14 | Test. 15 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/fixtures/remote5.txt: -------------------------------------------------------------------------------- 1 | Return-Path: 2 | Delivered-To: foo@example.com 3 | Received: from test1.example.com (test1.example.com [192.168.10.10]) 4 | by test2.example.com (Postfix) with ESMTP id E6F7890AF 5 | for ; Sat, 26 Jul 2008 20:09:04 -0600 (MDT) 6 | Message-ID: 7 | Date: Sat, 26 Jul 2008 21:10:01 -0500 (CDT) 8 | From: Test 9 | To: foo@example.com 10 | Subject: Test e-mail 1 11 | Mime-Version: 1.0 12 | Content-Type: text/plain 13 | 14 | Test. 15 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/fixtures/remote3.txt: -------------------------------------------------------------------------------- 1 | Return-Path: 2 | Delivered-To: foo2@example.com 3 | Received: from test2.example.com (test2.example.com [192.168.10.10]) 4 | by test3.example.com (Postfix) with ESMTP id JJKKAA 5 | for ; Sat, 26 Jul 2008 21:29:23 -0600 (MDT) 6 | Message-ID: 7 | Date: Sat, 26 Jul 2008 22:29:20 -0500 (CDT) 8 | From: Test 2 9 | To: foo2@example.com 10 | Subject: Re: Test e-mail 3 11 | Mime-Version: 1.0 12 | Content-Type: text/plain 13 | 14 | 3rd test message. 15 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/fixtures/remote2.txt: -------------------------------------------------------------------------------- 1 | Return-Path: 2 | Delivered-To: foo@example.com 3 | Received: from test1.example.com (test1.example.com [192.168.10.10]) 4 | by test2.example.com (Postfix) with ESMTP id E8796FBA 5 | for ; Sat, 26 Jul 2008 21:19:13 -0600 (MDT) 6 | Message-ID: <98761234@test1.example.com> 7 | Date: Sat, 26 Jul 2008 21:19:00 -0500 (CDT) 8 | From: Test 9 | To: foo@example.com 10 | Subject: Re: Test e-mail 1 11 | Mime-Version: 1.0 12 | Content-Type: text/plain 13 | In-Reply-To: 14 | References: 15 | 16 | 17 | Test reply. 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.6 4 | - 7.0 5 | - 7.1 6 | - 7.2 7 | - 7.3 8 | - 7.4 9 | - nightly 10 | jobs: 11 | fast_finish: true 12 | allow_failures: 13 | - php: nightly 14 | services: 15 | - mongodb 16 | before_script: 17 | - export IMAPCLIENT_TEST_CONFIG='{"mongo":"localhost"}'; 18 | - if [ "$TRAVIS_PHP_VERSION" == "7.0" ] || [ $(echo "$TRAVIS_PHP_VERSION 7.0" | tr " " "\n" | sort -V | head -n1) = "7.0" ]; 19 | then 20 | phpenv config-add .travis.php7.ini; 21 | else 22 | phpenv config-add .travis.ini; 23 | fi 24 | - phpenv config-rm xdebug.ini || echo "XDebug not enabled" 25 | - pear install channel://pear.horde.org/Horde_Test 26 | - pear install -a -B package.xml 27 | script: 28 | - php $(pear config-get php_dir)/Horde/Test/vendor/phpunit/phpunit/phpunit 29 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Exception.php: -------------------------------------------------------------------------------- 1 | 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_Exception extends Horde_Exception_Wrapped 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/AclNegative.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2011-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_AclNegative extends Horde_Imap_Client_Data_Acl 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Interaction/Server/Untagged.php: -------------------------------------------------------------------------------- 1 | 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_Interaction_Server_Untagged extends Horde_Imap_Client_Interaction_Server 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Interaction/Server/Continuation.php: -------------------------------------------------------------------------------- 1 | 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_Interaction_Server_Continuation extends Horde_Imap_Client_Interaction_Server 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/String/Support/Nonascii.php: -------------------------------------------------------------------------------- 1 | 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 | * @since 2.25.0 24 | */ 25 | interface Horde_Imap_Client_Data_Format_String_Support_Nonascii 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Astring/Nonascii.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.25.0 23 | */ 24 | class Horde_Imap_Client_Data_Format_Astring_Nonascii 25 | extends Horde_Imap_Client_Data_Format_Astring 26 | implements Horde_Imap_Client_Data_Format_String_Support_Nonascii 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Nstring/Nonascii.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.25.0 23 | */ 24 | class Horde_Imap_Client_Data_Format_Nstring_Nonascii 25 | extends Horde_Imap_Client_Data_Format_Nstring 26 | implements Horde_Imap_Client_Data_Format_String_Support_Nonascii 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/String/Nonascii.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.25.0 23 | */ 24 | class Horde_Imap_Client_Data_Format_String_Nonascii 25 | extends Horde_Imap_Client_Data_Format_String 26 | implements Horde_Imap_Client_Data_Format_String_Support_Nonascii 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Base/Password.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2013-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.14.0 23 | */ 24 | interface Horde_Imap_Client_Base_Password 25 | { 26 | /** 27 | * Return the password to use for the server connection. 28 | * 29 | * @return string The password. 30 | */ 31 | public function getPassword(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Astring.php: -------------------------------------------------------------------------------- 1 | 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_Astring extends Horde_Imap_Client_Data_Format_String 24 | { 25 | /** 26 | */ 27 | public function quoted() 28 | { 29 | return $this->_filter->quoted || !$this->_data->length(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Fetch/FetchTest.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2015-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class FetchTest extends TestBase 28 | { 29 | protected function _setUp() 30 | { 31 | $this->ob_class = 'Horde_Imap_Client_Data_Fetch'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Fetch/FetchPop3Test.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2015-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class FetchPop3Test extends TestBase 28 | { 29 | protected function _setUp() 30 | { 31 | $this->ob_class = 'Horde_Imap_Client_Data_Fetch_Pop3'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Exception/Sync.php: -------------------------------------------------------------------------------- 1 | 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_Exception_Sync extends Horde_Exception_Wrapped 24 | { 25 | /* Error message codes. */ 26 | 27 | /** 28 | * Token could not be parsed. 29 | */ 30 | const BAD_TOKEN = 1; 31 | 32 | /** 33 | * UIDVALIDITY of the mailbox changed. 34 | */ 35 | const UIDVALIDITY_CHANGED = 2; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Fetch/Pop3.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2011-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_Fetch_Pop3 extends Horde_Imap_Client_Data_Fetch 24 | { 25 | /** 26 | * Set UID. 27 | * 28 | * @param string $uid The message UID. Unlike IMAP, this UID does not 29 | * have to be an integer. 30 | */ 31 | public function setUid($uid) 32 | { 33 | $this->_data[Horde_Imap_Client::FETCH_UID] = strval($uid); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/DateTime.php: -------------------------------------------------------------------------------- 1 | 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_DateTime extends Horde_Imap_Client_Data_Format_Date 24 | { 25 | /** 26 | */ 27 | public function __toString() 28 | { 29 | return $this->_data->format('j-M-Y H:i:s O'); 30 | } 31 | 32 | /** 33 | */ 34 | public function escape() 35 | { 36 | return '"' . strval($this) . '"'; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Stub/Scram.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2015-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Scram extends Horde_Imap_Client_Auth_Scram 30 | { 31 | /** 32 | */ 33 | public function setNonce($nonce) 34 | { 35 | $this->_nonce = $nonce; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/ListMailbox.php: -------------------------------------------------------------------------------- 1 | 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_ListMailbox 24 | extends Horde_Imap_Client_Data_Format_Mailbox 25 | { 26 | /** 27 | */ 28 | protected function _filterParams() 29 | { 30 | $ob = parent::_filterParams(); 31 | 32 | /* Don't quote % or * characters. */ 33 | $ob->no_quote_list = true; 34 | 35 | return $ob; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Stub/Utf7imap.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Utf7imap extends Horde_Imap_Client_Utf7imap 30 | { 31 | public static function setMbstring($val) 32 | { 33 | self::$_mbstring = (bool)$val; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Fetch/Results/FetchTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2015-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class FetchTest extends TestBase 29 | { 30 | protected function _setUp() 31 | { 32 | $this->ob_class = 'Horde_Imap_Client_Data_Fetch'; 33 | $this->ob_ids = array(1, 2, 3); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Translation.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2010-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 21 | * @package Imap_Client 22 | */ 23 | class Horde_Imap_Client_Translation extends Horde_Translation_Autodetect 24 | { 25 | /** 26 | * The translation domain 27 | * 28 | * @var string 29 | */ 30 | protected static $_domain = 'Horde_Imap_Client'; 31 | 32 | /** 33 | * The absolute PEAR path to the translations for the default gettext handler. 34 | * 35 | * @var string 36 | */ 37 | protected static $_pearDirectory = '@data_dir@'; 38 | } 39 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/fixtures/clientsort2.txt: -------------------------------------------------------------------------------- 1 | KiAxIEZFVENIIChVSUQgMSBGTEFHUyAoXFNlZW4pIFJGQzgyMi5TSVpFIDM4NzUxIElOVEVSTkFMREFURSAiMDEtQXVnLTIwMTQgMDc6MzA6MDAgLTA3MDAiIEVOVkVMT1BFICgiVGh1LCAwMiBNYXkgMjAwMiAxNjozMDoyMCArMDAwMCIgInBlYXItY3ZzIERpZ2VzdCAyIE1heSAyMDAyIDE2OjMwOjIwIC0wMDAwIElzc3VlIDI1NyIgKChOSUwgTklMICJwZWFyLWN2cy1kaWdlc3QtaGVscCIgImxpc3RzLnBocC5uZXQiKSkgKChOSUwgTklMICJwZWFyLWN2cy1kaWdlc3QtaGVscCIgImxpc3RzLnBocC5uZXQiKSkgKChOSUwgTklMICJwZWFyLWN2cy1kaWdlc3QtaGVscCIgImxpc3RzLnBocC5uZXQiKSkgKChOSUwgTklMICJwZWFyLWN2cyIgImxpc3RzLnBocC5uZXQiKSkgTklMIE5JTCBOSUwgIjwxMDIwMzU3MDIwLjk5NTUwLmV6bWxtQGxpc3RzLnBocC5uZXQ+IikpCiogMiBGRVRDSCAoVUlEIDIgRkxBR1MgKFxTZWVuKSBSRkM4MjIuU0laRSAzODc1MSBJTlRFUk5BTERBVEUgIjAxLUF1Zy0yMDE0IDA3OjMwOjAwIC0wNzAwIiBFTlZFTE9QRSAoIlRodSwgMDIgTWF5IDIwMDIgMTc6MzA6MjAgKzAwMDAiICJwZWFyLWN2cyBEaWdlc3QgMiBNYXkgMjAwMiAxNjozMDoyMCAtMDAwMCBJc3N1ZSAyNTciICgoTklMIE5JTCAicGVhci1jdnMtZGlnZXN0LWhlbHAiICJsaXN0cy5waHAubmV0IikpICgoTklMIE5JTCAicGVhci1jdnMtZGlnZXN0LWhlbHAiICJsaXN0cy5waHAubmV0IikpICgoTklMIE5JTCAicGVhci1jdnMtZGlnZXN0LWhlbHAiICJsaXN0cy5waHAubmV0IikpICgoTklMIE5JTCAicGVhci1jdnMiICJsaXN0cy5waHAubmV0IikpIE5JTCBOSUwgTklMICI8MTAyMDM1NzAyMC45OTU1MC5lem1sbUBsaXN0cy5waHAubmV0PiIpKQo= 2 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Fetch/Results/FetchPop3Test.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2015-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class FetchPop3Test extends TestBase 29 | { 30 | protected function _setUp() 31 | { 32 | $this->ob_class = 'Horde_Imap_Client_Data_Fetch_Pop3'; 33 | $this->ob_ids = array('a', 'b', 'c'); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Nil.php: -------------------------------------------------------------------------------- 1 | 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_Nil extends Horde_Imap_Client_Data_Format 24 | { 25 | /** 26 | */ 27 | public function __construct($data = null) 28 | { 29 | // Don't store any data in object. 30 | } 31 | 32 | /** 33 | */ 34 | public function __toString() 35 | { 36 | return ''; 37 | } 38 | 39 | /** 40 | */ 41 | public function escape() 42 | { 43 | return 'NIL'; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/String/NonasciiTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NonasciiTest extends StringTest 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_String_Nonascii'; 31 | 32 | public function nonasciiInputProvider() 33 | { 34 | return array( 35 | array(true) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Astring/NonasciiTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NonasciiTest extends AstringTest 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_Astring_Nonascii'; 31 | 32 | public function nonasciiInputProvider() 33 | { 34 | return array( 35 | array(true) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Nstring/NonasciiTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NonasciiTest extends NstringTest 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_Nstring_Nonascii'; 31 | 32 | public function nonasciiInputProvider() 33 | { 34 | return array( 35 | array(true) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/ListMailbox/Utf8.php: -------------------------------------------------------------------------------- 1 | 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_ListMailbox_Utf8 25 | extends Horde_Imap_Client_Data_Format_Mailbox_Utf8 26 | { 27 | /** 28 | */ 29 | protected function _filterParams() 30 | { 31 | $ob = parent::_filterParams(); 32 | 33 | /* Don't quote % or * characters. */ 34 | $ob->no_quote_list = true; 35 | 36 | return $ob; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Number.php: -------------------------------------------------------------------------------- 1 | 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_Number extends Horde_Imap_Client_Data_Format 24 | { 25 | /** 26 | */ 27 | public function __toString() 28 | { 29 | return strval(intval($this->_data)); 30 | } 31 | 32 | /** 33 | */ 34 | public function verify() 35 | { 36 | if (!is_numeric($this->_data)) { 37 | throw new Horde_Imap_Client_Data_Format_Exception('Illegal character in IMAP number.'); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Cache/CacheTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2013-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class CacheTest extends TestBase 30 | { 31 | protected function _getBackend() 32 | { 33 | $factory_cache = new Horde_Test_Factory_Cache(); 34 | 35 | return new Horde_Imap_Client_Cache_Backend_Cache(array( 36 | 'cacheob' => $factory_cache->create() 37 | )); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Exception/NoSupportPop3.php: -------------------------------------------------------------------------------- 1 | 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_Exception_NoSupportPop3 24 | extends Horde_Imap_Client_Exception 25 | { 26 | /** 27 | * Constructor. 28 | * 29 | * @param string $feature The feature not supported in POP3. 30 | */ 31 | public function __construct($feature) 32 | { 33 | parent::__construct( 34 | Horde_Imap_Client_Translation::r("%s not supported on POP3 servers."), 35 | self::NOT_SUPPORTED 36 | ); 37 | $this->messagePrintf(array($feature)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/conf.php.dist: -------------------------------------------------------------------------------- 1 | false, 6 | 7 | // Configuration for the remote IMAP server test. 8 | 'client_config' => array( 9 | 'username' => '', 10 | 'password' => '', 11 | 'hostspec' => '', 12 | 'port' => '', 13 | 'secure' => true, // true, false, 'ssl', or 'tls' 14 | 'debug' => null, // e.g. 'php://output', 15 | // Test for XOAUTH2 16 | //'xoauth2_token' => '' 17 | ), 18 | ), 19 | ); 20 | 21 | $conf['pop3client'] = array( 22 | // Add array entry for every POP3 client to test. 23 | array( 24 | 'enabled' => false, 25 | 26 | // Configuration for the remote POP3 server test. 27 | 'client_config' => array( 28 | 'username' => '', 29 | 'password' => '', 30 | 'hostspec' => '', 31 | 'port' => '', 32 | 'secure' => true, // true, false, 'ssl', or 'tls' 33 | 'debug' => null // e.g. 'php://output' 34 | ), 35 | ), 36 | ); 37 | 38 | // Configuration for the Mongo cache driver test. 39 | // Format: mongodb://[username:password@]host 40 | $conf['mongo'] = null; 41 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Live/Base.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2014-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class Base extends TestCase 29 | { 30 | public static $live; 31 | 32 | public static function tearDownAfterClass() 33 | { 34 | self::$live = null; 35 | } 36 | 37 | public function onNotSuccessfulTest(Exception $e) 38 | { 39 | if ($e instanceof Horde_Imap_Client_Exception) { 40 | $e->setMessage($e->getMessage() . ' [' . self::$live->url . ']'); 41 | } 42 | parent::onNotSuccessfulTest($e); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Url/Imap/Relative.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2008-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.25.0 23 | */ 24 | class Horde_Imap_Client_Url_Imap_Relative 25 | extends Horde_Imap_Client_Url_Imap 26 | { 27 | /** 28 | * Create a relative IMAP URL (RFC 5092/5593). 29 | * 30 | * @return string A URL string. 31 | */ 32 | public function __toString() 33 | { 34 | if ($out = $this->_toImapString()) { 35 | if (substr($out, 0, 2) === '/;') { 36 | $out = substr($out, 1); 37 | } elseif ($out[0] !== ';') { 38 | $out = '/' . $out; 39 | } 40 | } 41 | 42 | return $out; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Stub/ClientSort.php: -------------------------------------------------------------------------------- 1 | 25 | * @category Horde 26 | * @copyright 2014-2016 Horde LLC 27 | * @ignore 28 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 29 | * @package Imap_Client 30 | * @subpackage UnitTests 31 | */ 32 | class ClientSort extends Horde_Imap_Client_Socket_ClientSort 33 | { 34 | public function __construct(Horde_Imap_Client_Socket $socket) 35 | { 36 | parent::__construct($socket); 37 | 38 | if (class_exists('Collator')) { 39 | $this->_collator = new Collator('root'); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.horde.yml: -------------------------------------------------------------------------------- 1 | --- 2 | id: Imap_Client 3 | name: Imap_Client 4 | full: IMAP client library 5 | description: >- 6 | A library to access IMAP4rev1 (RFC 3501) mail servers. Also supports 7 | connections to POP3 (STD 53/RFC 1939). 8 | list: dev 9 | type: library 10 | homepage: https://www.horde.org/libraries/Horde_Imap_Client 11 | authors: 12 | - 13 | name: Michael Slusarz 14 | user: slusarz 15 | email: slusarz@horde.org 16 | active: false 17 | role: lead 18 | version: 19 | release: 3.0.0alpha6 20 | api: 3.0.0alpha1 21 | state: 22 | release: alpha 23 | api: alpha 24 | license: 25 | identifier: LGPL-2.1-only 26 | uri: http://www.horde.org/licenses/lgpl21 27 | dependencies: 28 | required: 29 | php: ^7.4 || ^8 30 | composer: 31 | horde/exception: ^3 32 | horde/mail: ^3 33 | horde/mime: ^3 34 | horde/socket_client: ^3 35 | horde/stream: ^2 36 | horde/secret: ^3 37 | horde/stream_filter: ^3 38 | horde/translation: ^3 39 | horde/util: ^3 40 | ext: 41 | hash: '*' 42 | json: '*' 43 | optional: 44 | composer: 45 | horde/cache: ^3 46 | horde/compress_fast: ^2 47 | horde/crypt_blowfish: ^2 48 | horde/db: ^3 49 | horde/hashtable: ^2 50 | horde/mongo: ^2 51 | horde/pack: ^2 52 | horde/stringprep: ^2 53 | horde/support: ^3 54 | horde/test: ^3 55 | ext: 56 | intl: '*' 57 | mbstring: '*' 58 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Interaction/Server/Tagged.php: -------------------------------------------------------------------------------- 1 | 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_Interaction_Server_Tagged 24 | extends Horde_Imap_Client_Interaction_Server 25 | { 26 | /** 27 | * Tag. 28 | * 29 | * @var string 30 | */ 31 | public $tag; 32 | 33 | /** 34 | * @param string $tag Response tag. 35 | */ 36 | public function __construct(Horde_Imap_Client_Tokenize $token, $tag) 37 | { 38 | $this->tag = $tag; 39 | 40 | parent::__construct($token); 41 | 42 | if (is_null($this->status)) { 43 | throw new Horde_Imap_Client_Exception( 44 | Horde_Imap_Client_Translation::r("Bad tagged response.") 45 | ); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Date.php: -------------------------------------------------------------------------------- 1 | 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_Date extends Horde_Imap_Client_Data_Format 24 | { 25 | /** 26 | * Constructor. 27 | * 28 | * @param mixed $data Either a DateTime object, or a date format that 29 | * can be converted to a DateTime object. 30 | * 31 | * @throws Exception 32 | */ 33 | public function __construct($data) 34 | { 35 | if (!($data instanceof DateTime)) { 36 | $data = new Horde_Imap_Client_DateTime($data); 37 | } 38 | 39 | parent::__construct($data); 40 | } 41 | 42 | /** 43 | */ 44 | public function __toString() 45 | { 46 | return $this->_data->format('j-M-Y'); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Cache/HashtableTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2013-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class HashtableTest extends TestBase 30 | { 31 | protected function _getBackend() 32 | { 33 | $factory_hashtable = new Horde_Test_Factory_Hashtable(); 34 | 35 | if (!class_exists('Horde_Imap_Client_Cache_Backend_Hashtable')) { 36 | $this->markTestSkipped('HashTable not available.'); 37 | } else { 38 | return new Horde_Imap_Client_Cache_Backend_Hashtable(array( 39 | 'hashtable' => $factory_hashtable->create() 40 | )); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Url/BaseTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2014-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class BaseTest extends TestCase 29 | { 30 | /** 31 | * @dataProvider badUrlProvider 32 | */ 33 | public function testBadUrl($classname) 34 | { 35 | $url = new $classname('NOT A VALID URL'); 36 | 37 | $this->assertNull($url->hostspec); 38 | } 39 | 40 | public function badUrlProvider() 41 | { 42 | return array( 43 | array('Horde_Imap_Client_Url'), 44 | array('Horde_Imap_Client_Url_Imap'), 45 | array('Horde_Imap_Client_Url_Imap_Relative'), 46 | array('Horde_Imap_Client_Url_Pop3') 47 | ); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Exception/SearchCharset.php: -------------------------------------------------------------------------------- 1 | 19 | * @category Horde 20 | * @copyright 2012-2017 Horde LLC 21 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 | * @package Imap_Client 23 | */ 24 | class Horde_Imap_Client_Exception_SearchCharset 25 | extends Horde_Imap_Client_Exception 26 | { 27 | /** 28 | * Charset that was attempted to be converted to. 29 | * 30 | * @var string 31 | */ 32 | public $charset; 33 | 34 | /** 35 | * Constructor. 36 | * 37 | * @param string $charset The charset that was attempted to be converted 38 | * to. 39 | */ 40 | public function __construct($charset) 41 | { 42 | $this->charset = $charset; 43 | 44 | parent::__construct( 45 | Horde_Imap_Client_Translation::r("Cannot convert search query text to new charset"), 46 | self::BADCHARSET 47 | ); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Xoauth2Test.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2013-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Xoauth2Test extends TestCase 30 | { 31 | public function testTokenGeneration() 32 | { 33 | // Example from https://developers.google.com/gmail/xoauth2_protocol 34 | $xoauth2 = new Horde_Imap_Client_Password_Xoauth2( 35 | 'someuser@example.com', 36 | 'vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==' 37 | ); 38 | 39 | $this->assertEquals( 40 | 'dXNlcj1zb21ldXNlckBleGFtcGxlLmNvbQFhdXRoPUJlYXJlciB2RjlkZnQ0cW1UYzJOdmIzUmxja0JoZEhSaGRtbHpkR0V1WTI5dENnPT0BAQ==', 41 | $xoauth2->getPassword() 42 | ); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /migration/Horde/Imap/Client/2_horde_imap_client_change_column_name.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @ignore 21 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 | * @package Imap_Client 23 | */ 24 | class HordeImapClientChangeColumnName extends Horde_Db_Migration_Base 25 | { 26 | public function up() 27 | { 28 | if (array_key_exists('uid', $this->columns('horde_imap_client_data'))) { 29 | $this->renameColumn('horde_imap_client_data', 'uid', 'messageid'); 30 | } 31 | if (array_key_exists('uid', $this->columns('horde_imap_client_message'))) { 32 | $this->renameColumn('horde_imap_client_message', 'uid', 'messageid'); 33 | } 34 | if (array_key_exists('uid', $this->columns('horde_imap_client_metadata'))) { 35 | $this->renameColumn('horde_imap_client_metadata', 'uid', 'messageid'); 36 | } 37 | } 38 | 39 | public function down() 40 | { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Stub/DigestMD5.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class DigestMD5 extends Horde_Imap_Client_Auth_DigestMD5 30 | { 31 | /** 32 | * Cnonce to use. 33 | * 34 | * @var string 35 | */ 36 | protected $_cnonce; 37 | 38 | /** 39 | */ 40 | public function __construct($id, $pass, $challenge, $hostname, $service, 41 | $cnonce) 42 | { 43 | $this->_cnonce = $cnonce; 44 | parent::__construct($id, $pass, $challenge, $hostname, $service); 45 | } 46 | 47 | /** 48 | */ 49 | protected function _getCnonce() 50 | { 51 | return $this->_cnonce; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/TestBase.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | abstract class TestBase extends TestCase 30 | { 31 | abstract protected function getTestObs(); 32 | 33 | protected function createProviderArray($data) 34 | { 35 | $data = array_values($data); 36 | $out = array(); 37 | 38 | foreach (array_values($this->getTestObs()) as $key => $val) { 39 | $out[] = array_merge( 40 | array($val), 41 | isset($data[$key]) ? (is_array($data[$key]) ? $data[$key] : array($data[$key])) : array() 42 | ); 43 | } 44 | 45 | return $out; 46 | } 47 | 48 | public function obsProvider() 49 | { 50 | return $this->createProviderArray(array()); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/NilTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NilTest extends TestBase 29 | { 30 | protected function getTestObs() 31 | { 32 | return array( 33 | new Horde_Imap_Client_Data_Format_Nil(), 34 | /* Argument is ignored. */ 35 | new Horde_Imap_Client_Data_Format_Nil('Foo') 36 | ); 37 | } 38 | 39 | /** 40 | * @dataProvider obsProvider 41 | */ 42 | public function testStringRepresentation($ob) 43 | { 44 | $this->assertEquals( 45 | '', 46 | strval($ob) 47 | ); 48 | } 49 | 50 | /** 51 | * @dataProvider obsProvider 52 | */ 53 | public function testEscape($ob) 54 | { 55 | $this->assertEquals( 56 | 'NIL', 57 | $ob->escape() 58 | ); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Url/Pop3.php: -------------------------------------------------------------------------------- 1 | ;auth=@: 19 | * 20 | * @author Michael Slusarz 21 | * @category Horde 22 | * @copyright 2014-2017 Horde LLC 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @since 2.25.0 26 | */ 27 | class Horde_Imap_Client_Url_Pop3 extends Horde_Imap_Client_Url_Base 28 | { 29 | /** 30 | */ 31 | public function __get($name) 32 | { 33 | switch ($name) { 34 | case 'port': 35 | return parent::__get($name) ?: 110; 36 | 37 | default: 38 | return parent::__get($name); 39 | } 40 | } 41 | 42 | /** 43 | * Create a POP3 URL (RFC 2384). 44 | * 45 | * @return string A URL string. 46 | */ 47 | public function __toString() 48 | { 49 | $url = 'pop://' . parent::__toString(); 50 | 51 | if (($port = $this->port) != 110) { 52 | $url .= ':' . $port; 53 | } 54 | 55 | return $url . '/'; 56 | } 57 | 58 | /** 59 | */ 60 | protected function _parseUrl(array $data) 61 | { 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Cache/DbTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2013-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class DbTest extends TestBase 30 | { 31 | protected function _getBackend() 32 | { 33 | $factory_db = new Horde_Test_Factory_Db(); 34 | 35 | try { 36 | $db = $factory_db->create(array( 37 | 'migrations' => array( 38 | 'migrationsPath' => __DIR__ . '/../../../../../migration/Horde/Imap/Client' 39 | ) 40 | )); 41 | } catch (Horde_Test_Exception $e) { 42 | $this->markTestSkipped('Sqlite not available.'); 43 | } 44 | 45 | return new Horde_Imap_Client_Cache_Backend_Db(array( 46 | 'db' => $db, 47 | 'hostspec' => self::HOSTSPEC, 48 | 'port' => self::PORT, 49 | 'username' => self::USERNAME 50 | )); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Exception/NoSupportExtension.php: -------------------------------------------------------------------------------- 1 | 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_Exception_NoSupportExtension 24 | extends Horde_Imap_Client_Exception 25 | { 26 | /** 27 | * The extension not supported on the server. 28 | * 29 | * @var string 30 | */ 31 | public $extension; 32 | 33 | /** 34 | * Constructor. 35 | * 36 | * @param string $extension The extension not supported on the server. 37 | * @param string $msg A non-standard error message to use instead 38 | * of the default. 39 | */ 40 | public function __construct($extension, $msg = null) 41 | { 42 | $this->extension = $extension; 43 | 44 | if (is_null($msg)) { 45 | $msg = sprintf( 46 | Horde_Imap_Client_Translation::r("The server does not support the %s extension."), 47 | $extension 48 | ); 49 | } 50 | 51 | parent::__construct($msg, self::NOT_SUPPORTED); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Interaction/Client.php: -------------------------------------------------------------------------------- 1 | 19 | * @category Horde 20 | * @copyright 2012-2016 Horde LLC 21 | * @deprecated 22 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 23 | * @package Imap_Client 24 | */ 25 | class Horde_Imap_Client_Interaction_Client extends Horde_Imap_Client_Data_Format_List 26 | { 27 | /** 28 | * The command tag. 29 | * 30 | * @var string 31 | */ 32 | public $tag; 33 | 34 | /** 35 | * Constructor. 36 | * 37 | * @param string $tag The tag to use. If not set, will be automatically 38 | * generated. 39 | */ 40 | public function __construct($tag = null) 41 | { 42 | $this->tag = is_null($tag) 43 | ? substr(strval(new Horde_Support_Randomid()), 0, 10) 44 | : strval($tag); 45 | 46 | parent::__construct($this->tag); 47 | } 48 | 49 | /** 50 | * Get the command. 51 | * 52 | * @return string The command. 53 | */ 54 | public function getCommand() 55 | { 56 | return isset($this->_data[1]) 57 | ? $this->_data[1] 58 | : null; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Atom.php: -------------------------------------------------------------------------------- 1 | 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_Atom extends Horde_Imap_Client_Data_Format 24 | { 25 | /** 26 | */ 27 | public function escape() 28 | { 29 | return strlen($this->_data) 30 | ? parent::escape() 31 | : '""'; 32 | } 33 | 34 | /** 35 | */ 36 | public function verify() 37 | { 38 | if (strlen($this->_data) !== strlen($this->stripNonAtomCharacters())) { 39 | throw new Horde_Imap_Client_Data_Format_Exception('Illegal character in IMAP atom.'); 40 | } 41 | } 42 | 43 | /** 44 | * Strip out any characters that are not allowed in an IMAP atom. 45 | * 46 | * @return string The atom data disallowed characters removed. 47 | */ 48 | public function stripNonAtomCharacters() 49 | { 50 | return str_replace( 51 | array('(', ')', '{', ' ', '%', '*', '"', '\\', ']'), 52 | '', 53 | preg_replace('/[^\x20-\x7e]/', '', $this->_data) 54 | ); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Cache/Backend/Null.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2013-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | */ 23 | class Horde_Imap_Client_Cache_Backend_Null 24 | extends Horde_Imap_Client_Cache_Backend 25 | { 26 | /** 27 | */ 28 | public function get($mailbox, $uids, $fields, $uidvalid) 29 | { 30 | return array(); 31 | } 32 | 33 | /** 34 | */ 35 | public function getCachedUids($mailbox, $uidvalid) 36 | { 37 | return array(); 38 | } 39 | 40 | /** 41 | */ 42 | public function set($mailbox, $data, $uidvalid) 43 | { 44 | } 45 | 46 | /** 47 | */ 48 | public function getMetaData($mailbox, $uidvalid, $entries) 49 | { 50 | return array( 51 | 'uidvalid' => 0 52 | ); 53 | } 54 | 55 | /** 56 | */ 57 | public function setMetaData($mailbox, $data) 58 | { 59 | } 60 | 61 | /** 62 | */ 63 | public function deleteMsgs($mailbox, $uids) 64 | { 65 | } 66 | 67 | /** 68 | */ 69 | public function deleteMailbox($mailbox) 70 | { 71 | } 72 | 73 | /** 74 | */ 75 | public function clear($lifetime) 76 | { 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/SearchCharset/Utf8.php: -------------------------------------------------------------------------------- 1 | 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 | * @since 2.24.0 24 | */ 25 | class Horde_Imap_Client_Data_SearchCharset_Utf8 26 | extends Horde_Imap_Client_Data_SearchCharset 27 | { 28 | /** 29 | * Charset data. 30 | * 31 | * @var array 32 | */ 33 | protected $_charsets = array( 34 | 'US-ASCII' => true, 35 | 'UTF-8' => true 36 | ); 37 | 38 | /** 39 | */ 40 | public function query($charset, $cached = false) 41 | { 42 | return isset($this->_charsets[Horde_String::upper($charset)]); 43 | } 44 | 45 | /** 46 | */ 47 | public function setValid($charset, $valid = true) 48 | { 49 | } 50 | 51 | /* Serializable methods. */ 52 | 53 | /** 54 | */ 55 | public function serialize() 56 | { 57 | return ''; 58 | } 59 | 60 | /** 61 | */ 62 | public function unserialize($data) 63 | { 64 | } 65 | 66 | /** 67 | * @return array 68 | */ 69 | public function __serialize() 70 | { 71 | return array(); 72 | } 73 | 74 | public function __unserialize(array $data) 75 | { 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Url/TestBase.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2014-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | abstract class TestBase extends TestCase 29 | { 30 | protected $classname; 31 | 32 | /** 33 | * @dataProvider testUrlProvider 34 | */ 35 | public function testUrlParsing($in, $url, $expected) 36 | { 37 | $ob = new $this->classname($in); 38 | 39 | foreach ($expected as $key => $val) { 40 | $this->assertEquals( 41 | $val, 42 | $ob->$key 43 | ); 44 | } 45 | 46 | $this->assertEquals( 47 | is_null($url) ? $in : $url, 48 | strval($ob) 49 | ); 50 | } 51 | 52 | abstract public function testUrlProvider(); 53 | 54 | /** 55 | * @dataProvider serializeProvider() 56 | */ 57 | public function testSerialize($url) 58 | { 59 | $orig = new $this->classname($url); 60 | $copy = unserialize(serialize($orig)); 61 | 62 | $this->assertEquals( 63 | $orig, 64 | $copy 65 | ); 66 | } 67 | 68 | abstract public function serializeProvider(); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/DateTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class DateTest extends TestBase 30 | { 31 | protected function getTestObs() 32 | { 33 | return array( 34 | new Horde_Imap_Client_Data_Format_Date('January 1, 2010'), 35 | new Horde_Imap_Client_Data_Format_Date('@1262304000') 36 | ); 37 | } 38 | 39 | /** 40 | * @dataProvider obsProvider 41 | */ 42 | public function testConstructor($ob) 43 | { 44 | $this->assertEquals( 45 | new Horde_Imap_Client_DateTime('January 1, 2010'), 46 | $ob->getData() 47 | ); 48 | } 49 | 50 | /** 51 | * @dataProvider obsProvider 52 | */ 53 | public function testStringRepresentation($ob) 54 | { 55 | $this->assertEquals( 56 | '1-Jan-2010', 57 | strval($ob) 58 | ); 59 | } 60 | 61 | /** 62 | * @dataProvider obsProvider 63 | */ 64 | public function testEscape($ob) 65 | { 66 | $this->assertEquals( 67 | '1-Jan-2010', 68 | $ob->escape() 69 | ); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/AclTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class AclTest extends TestCase 30 | { 31 | public function testIterator() 32 | { 33 | $ob = new Horde_Imap_Client_Data_Acl('lrs'); 34 | 35 | $this->assertNotEmpty(count(iterator_to_array($ob))); 36 | } 37 | 38 | public function testSerialization() 39 | { 40 | $this->assertInstanceOf( 41 | 'Horde_Imap_Client_Data_Acl', 42 | unserialize(serialize(new Horde_Imap_Client_Data_Acl('lrs'))) 43 | ); 44 | } 45 | 46 | /** 47 | * @dataProvider bug10079Provider 48 | */ 49 | public function testBug10079($rights, $expected) 50 | { 51 | $ob = new Horde_Imap_Client_Data_Acl($rights); 52 | 53 | $this->assertEquals( 54 | $expected, 55 | strval($ob) 56 | ); 57 | } 58 | 59 | public function bug10079Provider() 60 | { 61 | return array( 62 | // RFC 2086 rights string 63 | array('lrswipcda', 'lrswipakxte'), 64 | // RFC 4314 rights string 65 | array('lrswipakte', 'lrswipakte') 66 | ); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Filter/Quote.php: -------------------------------------------------------------------------------- 1 | 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 | #[ReturnTypeWillChange] 35 | public function onCreate() 36 | { 37 | $this->_prepend = false; 38 | } 39 | 40 | /** 41 | * @see stream_filter_register() 42 | */ 43 | #[ReturnTypeWillChange] 44 | public function filter($in, $out, &$consumed, $closing) 45 | { 46 | if (!$this->_prepend) { 47 | stream_bucket_append($out, stream_bucket_new($this->stream, '"')); 48 | $this->_prepend = true; 49 | } 50 | 51 | while ($bucket = stream_bucket_make_writeable($in)) { 52 | $consumed += $bucket->datalen; 53 | $bucket->data = addcslashes($bucket->data, '"\\'); 54 | stream_bucket_append($out, $bucket); 55 | } 56 | 57 | /* feof() call needed due to: 58 | * http://news.php.net/php.internals/80363 */ 59 | if ($closing || feof($this->stream)) { 60 | stream_bucket_append($out, stream_bucket_new($this->stream, '"')); 61 | } 62 | 63 | return PSFS_PASS_ON; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Cache/MongoTest.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2013-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class MongoTest extends TestBase 28 | { 29 | private $_dbname = 'horde_imap_client_cache_mongodbtest'; 30 | private $_mongo; 31 | 32 | protected function _getBackend() 33 | { 34 | if (($config = self::getConfig('IMAPCLIENT_TEST_CONFIG', __DIR__ . '/..')) && 35 | isset($config['mongo'])) { 36 | $factory = new Horde_Test_Factory_Mongo(); 37 | $this->_mongo = $factory->create(array( 38 | 'config' => $config['mongo'], 39 | 'dbname' => $this->_dbname 40 | )); 41 | } 42 | 43 | if (empty($this->_mongo)) { 44 | $this->markTestSkipped('MongoDB not available.'); 45 | } 46 | 47 | return new Horde_Imap_Client_Cache_Backend_Mongo(array( 48 | 'hostspec' => self::HOSTSPEC, 49 | 'mongo_db' => $this->_mongo, 50 | 'port' => self::PORT, 51 | 'username' => self::USERNAME 52 | )); 53 | } 54 | 55 | public function tearDown(): void 56 | { 57 | if (!empty($this->_mongo)) { 58 | $this->_mongo->selectDB(null)->drop(); 59 | } 60 | 61 | parent::tearDown(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format.php: -------------------------------------------------------------------------------- 1 | 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 24 | { 25 | /** 26 | * Data. 27 | * 28 | * @var mixed 29 | */ 30 | protected $_data; 31 | 32 | /** 33 | * Constructor. 34 | * 35 | * @param mixed $data Data. 36 | */ 37 | public function __construct($data) 38 | { 39 | $this->_data = is_resource($data) 40 | ? stream_get_contents($data, -1, 0) 41 | : $data; 42 | } 43 | 44 | /** 45 | * Returns the string value of the raw data. 46 | * 47 | * @return string String value. 48 | */ 49 | public function __toString() 50 | { 51 | return strval($this->_data); 52 | } 53 | 54 | /** 55 | * Returns the raw data. 56 | * 57 | * @return mixed Raw data. 58 | */ 59 | public function getData() 60 | { 61 | return $this->_data; 62 | } 63 | 64 | /** 65 | * Returns the data formatted for output to the IMAP server. 66 | * 67 | * @return string IMAP escaped string. 68 | */ 69 | public function escape() 70 | { 71 | return strval($this); 72 | } 73 | 74 | /** 75 | * Verify the data. 76 | * 77 | * @throws Horde_Imap_Client_Data_Format_Exception 78 | */ 79 | public function verify() 80 | { 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/DateTimeTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class DateTimeTest extends TestBase 30 | { 31 | protected function getTestObs() 32 | { 33 | return array( 34 | new Horde_Imap_Client_Data_Format_DateTime('January 1, 2010'), 35 | new Horde_Imap_Client_Data_Format_DateTime('@1262304000') 36 | ); 37 | } 38 | 39 | /** 40 | * @dataProvider obsProvider 41 | */ 42 | public function testConstructor($ob) 43 | { 44 | $this->assertEquals( 45 | new Horde_Imap_Client_DateTime('January 1, 2010'), 46 | $ob->getData() 47 | ); 48 | } 49 | 50 | /** 51 | * @dataProvider obsProvider 52 | */ 53 | public function testStringRepresentation($ob) 54 | { 55 | $this->assertEquals( 56 | '1-Jan-2010 00:00:00 +0000', 57 | strval($ob) 58 | ); 59 | } 60 | 61 | /** 62 | * @dataProvider obsProvider 63 | */ 64 | public function testEscape($ob) 65 | { 66 | $this->assertEquals( 67 | '"1-Jan-2010 00:00:00 +0000"', 68 | $ob->escape() 69 | ); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Mailbox/Utf8.php: -------------------------------------------------------------------------------- 1 | 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 | } 58 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Password/Xoauth2.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2013-2017 Horde LLC 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @since 2.16.0 26 | */ 27 | class Horde_Imap_Client_Password_Xoauth2 28 | implements Horde_Imap_Client_Base_Password 29 | { 30 | /** 31 | * Access token. 32 | * 33 | * @var string 34 | */ 35 | public $access_token; 36 | 37 | /** 38 | * Username. 39 | * 40 | * @var string 41 | */ 42 | public $username; 43 | 44 | /** 45 | * Constructor. 46 | * 47 | * @param string $username The username. 48 | * @param string $access_token The access token. 49 | */ 50 | public function __construct($username, $access_token) 51 | { 52 | $this->username = $username; 53 | $this->access_token = $access_token; 54 | } 55 | 56 | /** 57 | * Return the password to use for the server connection. 58 | * 59 | * @return string The password. 60 | */ 61 | public function getPassword() 62 | { 63 | // base64("user=" {User} "^Aauth=Bearer " {Access Token} "^A^A") 64 | // ^A represents a Control+A (\001) 65 | return base64_encode( 66 | 'user=' . $this->username . "\1" . 67 | 'auth=Bearer ' . $this->access_token . "\1\1" 68 | ); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Ids/Pop3.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2011-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | */ 23 | class Horde_Imap_Client_Ids_Pop3 extends Horde_Imap_Client_Ids 24 | { 25 | /** 26 | */ 27 | protected function _sort(&$ids) 28 | { 29 | /* There is no guarantee of POP3 UIDL order - IDs need to be unique, 30 | * but there is no requirement they need be incrementing. RFC 31 | * 1939[7] */ 32 | } 33 | 34 | /** 35 | * Create a POP3 message sequence string. 36 | * 37 | * Index Format: UID1[SPACE]UID2... 38 | * 39 | * @param boolean $sort Not used in this class. 40 | * 41 | * @return string The POP3 message sequence string. 42 | */ 43 | protected function _toSequenceString($sort = true) 44 | { 45 | /* $sort is ignored - see _sort(). */ 46 | 47 | /* Use space as delimiter as it is the only printable ASCII character 48 | * that is not allowed as part of the UID (RFC 1939 [7]). */ 49 | return implode(' ', count($this->_ids) > 25000 ? array_unique($this->_ids) : array_keys(array_flip($this->_ids))); 50 | } 51 | 52 | /** 53 | * Parse a POP3 message sequence string into a list of indices. 54 | * 55 | * @param string $str The POP3 message sequence string. 56 | * 57 | * @return array An array of UIDs. 58 | */ 59 | protected function _fromSequenceString($str) 60 | { 61 | return explode(' ', trim($str)); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Live/ImapTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class ImapTest extends TestCase 30 | { 31 | /** 32 | * Add the tests to the current test runner. 33 | */ 34 | public static function suite() 35 | { 36 | $suite = new TestSuite; 37 | 38 | $c = self::getConfig('IMAPCLIENT_TEST_CONFIG', __DIR__ . '/../'); 39 | if (!is_null($c) && !empty($c['imapclient'])) { 40 | $key = 0; 41 | 42 | foreach ($c['imapclient'] as $val) { 43 | if (!empty($val['enabled']) && 44 | !empty($val['client_config']['username']) && 45 | !empty($val['client_config']['password'])) { 46 | /* Create a temp class for each instance to ensure that 47 | * no @depends mixing between servers occurs. */ 48 | $temp_class = 'Horde_Imap_Client_Live_Imap_' . ++$key; 49 | eval( 50 | "class $temp_class extends Horde_Imap_Client_Live_Imap {}" 51 | ); 52 | 53 | Horde_Imap_Client_Live_Imap::$config[] = $val; 54 | $suite->addTestSuite($temp_class); 55 | } 56 | } 57 | } 58 | 59 | return $suite; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Live/Pop3Test.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Pop3Test extends TestCase 30 | { 31 | /** 32 | * Add the tests to the current test runner. 33 | */ 34 | public static function suite() 35 | { 36 | $suite = new TestSuite; 37 | 38 | $c = self::getConfig('IMAPCLIENT_TEST_CONFIG_POP3', __DIR__ . '/../'); 39 | if (!is_null($c) && !empty($c['pop3client'])) { 40 | $key = 0; 41 | 42 | foreach ($c['pop3client'] as $val) { 43 | if (!empty($val['enabled']) && 44 | !empty($val['client_config']['username']) && 45 | !empty($val['client_config']['password'])) { 46 | /* Create a temp class for each instance to ensure that 47 | * no @depends mixing between servers occurs. */ 48 | $temp_class = 'Horde_Imap_Client_Live_Pop3_' . ++$key; 49 | eval( 50 | "class $temp_class extends Horde_Imap_Client_Live_Pop3 {}" 51 | ); 52 | 53 | Horde_Imap_Client_Live_Pop3::$config[] = $val; 54 | $suite->addTestSuite($temp_class); 55 | } 56 | } 57 | } 58 | 59 | return $suite; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "minimum-stability": "dev", 3 | "name": "horde/imap_client", 4 | "description": "IMAP client library", 5 | "type": "library", 6 | "homepage": "https://www.horde.org/libraries/Horde_Imap_Client", 7 | "license": "LGPL-2.1-only", 8 | "authors": [ 9 | { 10 | "name": "Michael Slusarz", 11 | "email": "slusarz@horde.org", 12 | "role": "lead" 13 | } 14 | ], 15 | "time": "2022-12-05", 16 | "repositories": [ 17 | { 18 | "type": "composer", 19 | "url": "https://horde-satis.maintaina.com" 20 | } 21 | ], 22 | "require": { 23 | "php": "^7.4 || ^8", 24 | "horde/exception": "^3 || dev-FRAMEWORK_6_0", 25 | "horde/mail": "^3 || dev-FRAMEWORK_6_0", 26 | "horde/mime": "^3 || dev-FRAMEWORK_6_0", 27 | "horde/socket_client": "^3 || dev-FRAMEWORK_6_0", 28 | "horde/stream": "^2 || dev-FRAMEWORK_6_0", 29 | "horde/secret": "^3 || dev-FRAMEWORK_6_0", 30 | "horde/stream_filter": "^3 || dev-FRAMEWORK_6_0", 31 | "horde/translation": "^3 || dev-FRAMEWORK_6_0", 32 | "horde/util": "^3 || dev-FRAMEWORK_6_0", 33 | "ext-hash": "*", 34 | "ext-json": "*" 35 | }, 36 | "require-dev": {}, 37 | "suggest": { 38 | "horde/cache": "^3 || dev-FRAMEWORK_6_0", 39 | "horde/compress_fast": "^2 || dev-FRAMEWORK_6_0", 40 | "horde/crypt_blowfish": "^2 || dev-FRAMEWORK_6_0", 41 | "horde/db": "^3 || dev-FRAMEWORK_6_0", 42 | "horde/hashtable": "^2 || dev-FRAMEWORK_6_0", 43 | "horde/mongo": "^2 || dev-FRAMEWORK_6_0", 44 | "horde/pack": "^2 || dev-FRAMEWORK_6_0", 45 | "horde/stringprep": "^2 || dev-FRAMEWORK_6_0", 46 | "horde/support": "^3 || dev-FRAMEWORK_6_0", 47 | "horde/test": "^3 || dev-FRAMEWORK_6_0", 48 | "ext-intl": "*", 49 | "ext-mbstring": "*" 50 | }, 51 | "autoload": { 52 | "psr-0": { 53 | "Horde_Imap_Client": "lib/" 54 | } 55 | }, 56 | "autoload-dev": { 57 | "psr-4": { 58 | "Horde\\Imap\\Client\\Test\\": "test/" 59 | } 60 | }, 61 | "config": { 62 | "allow-plugins": { 63 | "horde/horde-installer-plugin": true 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/AclCommon.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2011-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_AclCommon 24 | { 25 | /** Constants for getString(). */ 26 | const RFC_2086 = 1; 27 | const RFC_4314 = 2; 28 | 29 | /** 30 | * List of virtual rights (RFC 4314 [2.1.1]). 31 | * 32 | * @var array 33 | */ 34 | protected $_virtual = array( 35 | Horde_Imap_Client::ACL_CREATE => array( 36 | Horde_Imap_Client::ACL_CREATEMBOX, 37 | Horde_Imap_Client::ACL_DELETEMBOX 38 | ), 39 | Horde_Imap_Client::ACL_DELETE => array( 40 | Horde_Imap_Client::ACL_DELETEMSGS, 41 | // Don't put this first - we do checks on the existence of the 42 | // first element in this array to determine the RFC type, and this 43 | // is duplicate of right contained in ACL_CREATE. 44 | Horde_Imap_Client::ACL_DELETEMBOX, 45 | Horde_Imap_Client::ACL_EXPUNGE 46 | ) 47 | ); 48 | 49 | /** 50 | * Returns the raw string to use in IMAP server calls. 51 | * 52 | * @param integer $type The RFC type to use (RFC_* constant). 53 | * 54 | * @return string The string representation of the ACL. 55 | */ 56 | public function getString($type = self::RFC_4314) 57 | { 58 | $acl = strval($this); 59 | 60 | if ($type == self::RFC_2086) { 61 | foreach ($this->_virtual as $key => $val) { 62 | $acl = str_replace($val, '', $acl, $count); 63 | if ($count) { 64 | $acl .= $key; 65 | } 66 | } 67 | } 68 | 69 | return $acl; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Nstring.php: -------------------------------------------------------------------------------- 1 | 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_Nstring extends Horde_Imap_Client_Data_Format_String 24 | { 25 | /** 26 | */ 27 | public function __construct($data = null) 28 | { 29 | /* Data can be null (NIL) here. */ 30 | if (is_null($data)) { 31 | $this->_data = null; 32 | } else { 33 | parent::__construct($data); 34 | } 35 | } 36 | 37 | /** 38 | */ 39 | public function __toString() 40 | { 41 | return is_null($this->_data) 42 | ? '' 43 | : parent::__toString(); 44 | } 45 | 46 | /** 47 | */ 48 | public function escape() 49 | { 50 | return is_null($this->_data) 51 | ? 'NIL' 52 | : parent::escape(); 53 | } 54 | 55 | public function escapeStream() 56 | { 57 | if (is_null($this->_data)) { 58 | $stream = new Horde_Stream_Temp(); 59 | $stream->add('NIL', true); 60 | return $stream->stream; 61 | } 62 | 63 | return parent::escapeStream(); 64 | } 65 | 66 | /** 67 | */ 68 | public function quoted() 69 | { 70 | return is_null($this->_data) 71 | ? false 72 | : parent::quoted(); 73 | } 74 | 75 | /** 76 | */ 77 | public function length() 78 | { 79 | return is_null($this->_data) 80 | ? 0 81 | : parent::length(); 82 | } 83 | 84 | /** 85 | */ 86 | public function getStream() 87 | { 88 | return is_null($this->_data) 89 | ? new Horde_Stream_Temp() 90 | : parent::getStream(); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/SubjectParseTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class SubjectParseTest extends TestCase 30 | { 31 | /** 32 | * @dataProvider subjectParseProvider 33 | */ 34 | public function testSubjectParse($subject, $expected) 35 | { 36 | $this->assertEquals( 37 | $expected, 38 | strval(new Horde_Imap_Client_Data_BaseSubject($subject)) 39 | ); 40 | } 41 | 42 | public function subjectParseProvider() 43 | { 44 | // Format: Test string, Expected parse result 45 | return array( 46 | array('Test', 'Test'), 47 | array('Re: Test', 'Test'), 48 | array('re: Test', 'Test'), 49 | array('Fwd: Test', 'Test'), 50 | array('fwd: Test', 'Test'), 51 | array(' Fw: Test', 'Test'), 52 | array('fw: Test', 'Test'), 53 | array('fwd [foo] : Test', 'Test'), 54 | array('Fwd: Re: Test', 'Test'), 55 | array('Fwd: Re: Test (fwd)', 'Test'), 56 | array(' re : Test (fwd)', 'Test'), 57 | array(' re : [foo]Test(Fwd)', 'Test'), 58 | array("re \t: \tTest", 'Test'), 59 | array('Re:', ''), 60 | array(' RE : ', ''), 61 | array('Fwd:', ''), 62 | array(' FWD : ', ''), 63 | // This used to throw an undefined index error. 64 | array('fwd', 'fwd'), 65 | // Tabs 66 | array("Re: re:re: fwd:[fwd: \t Test] (fwd) (fwd)(fwd) ", 'Test') 67 | ); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Interaction/Command/Continuation.php: -------------------------------------------------------------------------------- 1 | 19 | * @category Horde 20 | * @copyright 2013-2017 Horde LLC 21 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 | * @package Imap_Client 23 | * @since 2.10.0 24 | */ 25 | class Horde_Imap_Client_Interaction_Command_Continuation 26 | { 27 | /** 28 | * Is this an optional continuation request? 29 | * 30 | * @since 2.13.0 31 | * @var boolean 32 | */ 33 | public $optional = false; 34 | 35 | /** 36 | * Closure function to run after continuation response. 37 | * 38 | * @var Closure 39 | */ 40 | protected $_closure; 41 | 42 | /** 43 | * Constructor. 44 | * 45 | * @param Closure $closure A function to run after the continuation 46 | * response is received. It receives one 47 | * argument - a Continuation object - and should 48 | * return a list of arguments to send to the 49 | * server (via a 50 | * Horde_Imap_Client_Data_Format_List object). 51 | */ 52 | public function __construct($closure) 53 | { 54 | $this->_closure = $closure; 55 | } 56 | 57 | /** 58 | * Calls the closure object. 59 | * 60 | * @param Horde_Imap_Client_Interaction_Server_Continuation $ob Continuation 61 | * object. 62 | * 63 | * @return Horde_Imap_Client_Data_Format_List Further commands to issue 64 | * to the server. 65 | */ 66 | public function getCommands( 67 | Horde_Imap_Client_Interaction_Server_Continuation $ob 68 | ) 69 | { 70 | $closure = $this->_closure; 71 | return $closure($ob); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Socket/Connection/Base.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2017 Horde LLC 24 | * @internal 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | */ 28 | class Horde_Imap_Client_Socket_Connection_Base extends Horde\Socket\Client 29 | { 30 | /** 31 | * Protocol type. 32 | * 33 | * @var string 34 | */ 35 | protected $_protocol = 'imap'; 36 | 37 | /** 38 | */ 39 | protected function _connect($host, $port, $timeout, $secure, $context, $retries = 0) 40 | { 41 | if ($retries || !$this->_params['debug']->debug) { 42 | $timer = null; 43 | } else { 44 | $url = ($this->_protocol == 'imap') 45 | ? new Horde_Imap_Client_Url_Imap() 46 | : new Horde_Imap_Client_Url_Pop3(); 47 | $url->host = $host; 48 | $url->port = $port; 49 | $this->_params['debug']->info(sprintf( 50 | 'Connection to: %s', 51 | strval($url) 52 | )); 53 | 54 | $timer = new Horde_Support_Timer(); 55 | $timer->push(); 56 | } 57 | 58 | try { 59 | parent::_connect($host, $port, $timeout, $secure, $context, $retries); 60 | } catch (Horde\Socket\Client\Exception $e) { 61 | $this->_params['debug']->info(sprintf( 62 | 'Connection failed: %s', 63 | $e->getMessage() 64 | )); 65 | throw $e; 66 | } 67 | 68 | if ($timer) { 69 | $this->_params['debug']->info(sprintf( 70 | 'Server connection took %s seconds.', 71 | round($timer->pop(), 4) 72 | )); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: make release 3 | 4 | # manual workflow to make a new release for the default branch 5 | on: 6 | workflow_dispatch: 7 | branches: 8 | - FRAMEWORK_6_0 9 | env: 10 | components: "/home/runner/.composer/web/components/bin/horde-components -c /home/runner/.composer/web/components/config/maintaina.conf.dist" 11 | 12 | jobs: 13 | run: 14 | runs-on: ${{ matrix.operating-system }} 15 | strategy: 16 | matrix: 17 | operating-system: ['ubuntu-20.04'] 18 | php-versions: ['8.1'] 19 | steps: 20 | - name: Setup git 21 | run: | 22 | mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts 23 | git config --global user.name "Github CI Runner" 24 | git config --global user.email "ci-job@maintaina.com" 25 | - name: Checkout 26 | uses: actions/checkout@v2 27 | with: 28 | fetch-depth: 0 29 | - name: Setup PHP 30 | uses: shivammathur/setup-php@v2 31 | with: 32 | php-version: ${{ matrix.php-versions }} 33 | extensions: gettext 34 | ini-values: post_max_size=512M, max_execution_time=360 35 | tools: composer:v2 36 | - name: Setup composer 37 | run: | 38 | composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} 39 | composer global config repositories.0 composer https://horde-satis.maintaina.com 40 | composer global config minimum-stability dev 41 | composer config --no-plugins --global allow-plugins.horde/horde-installer-plugin true 42 | composer global require horde/horde-installer-plugin "2.3.0" 43 | composer global require horde/components "dev-FRAMEWORK_6_0" 44 | - name: write changelog 45 | run: | 46 | entries_amount=0; max_entries=100 47 | PATTERN="^\[.*\] .*" 48 | 49 | for commit in $(git rev-list FRAMEWORK_6_0) 50 | do 51 | msg=$(git log --format=%B -n 1 $commit | head -n 1) 52 | if [ $entries_amount -gt $max_entries ]; then break; fi 53 | if [[ $msg == 'Released'* ]]; then break; fi 54 | if [[ $msg == 'Development mode for'* ]]; then break; fi 55 | if [[ $msg =~ $PATTERN ]]; then 56 | $components changed "$msg" 57 | let "entries_amount+=1" 58 | fi 59 | done 60 | - name: make release and push 61 | run: | 62 | $components release for maintaina 63 | git push 64 | git push origin --tags 65 | -------------------------------------------------------------------------------- /.github/workflows/update-satis.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Update Satis 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: 10 | - FRAMEWORK_6_0 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | run: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - name: Setup github ssh key 20 | run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts 21 | - name: Setup uut dir 22 | run: | 23 | export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") 24 | export UUT_DIR=$(pwd) 25 | export WORK_DIR=~ 26 | export BIN_DIR="${WORK_DIR}/bin" 27 | mkdir -p $BIN_DIR 28 | git config --global user.name "PHPDOC CI Job" 29 | git config --global user.email "ci-job@maintaina.com" 30 | - name: Checkout 31 | uses: actions/checkout@v2 32 | - name: Checkout satis web dir 33 | uses: actions/checkout@v2 34 | with: 35 | repository: maintaina-com/maintaina-com.github.io 36 | token: ${{secrets.PHPDOC_TOKEN}} 37 | path: "maintaina-com.github.io" 38 | - name: Setup PHP 39 | uses: shivammathur/setup-php@v2 40 | with: 41 | php-version: 7.4 42 | extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter 43 | ini-values: post_max_size=512M, max_execution_time=3600 44 | coverage: xdebug 45 | tools: composer:v2 46 | - name: Setup Github Token as composer credential 47 | run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} 48 | - name: Run Satis 49 | run: | 50 | export UUT_DIR=$(pwd) 51 | export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") 52 | export WORK_DIR=/home/runner/ 53 | export BIN_DIR="${WORK_DIR}/bin" 54 | composer create-project composer/satis:dev-main 55 | php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/${REPO,,} 56 | cd maintaina-com.github.io 57 | git add include/ index.html p2/ packages.json 58 | git commit -m "Update for horde/${REPO,,}" 59 | git push 60 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Ids/Pop3Test.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Pop3Test extends TestCase 30 | { 31 | /** 32 | * @dataProvider pop3SequenceStringGenerateProvider 33 | */ 34 | public function testPop3SequenceStringGenerate($in, $expected) 35 | { 36 | $this->assertEquals( 37 | $expected, 38 | strval(new Horde_Imap_Client_Ids_Pop3($in)) 39 | ); 40 | } 41 | 42 | public function pop3SequenceStringGenerateProvider() 43 | { 44 | return array( 45 | array(array('ABCDEFGHIJ', 'ABCDE'), 'ABCDEFGHIJ ABCDE'), 46 | array('ABCDEFGHIJ', 'ABCDEFGHIJ') 47 | ); 48 | } 49 | 50 | /** 51 | * @dataProvider pop3SequenceStringParseProvider 52 | */ 53 | public function testPop3SequenceStringParse($in, $expected) 54 | { 55 | $ids = new Horde_Imap_Client_Ids_Pop3($in); 56 | $this->assertEquals( 57 | $expected, 58 | $ids->ids 59 | ); 60 | } 61 | 62 | public function pop3SequenceStringParseProvider() 63 | { 64 | return array( 65 | array('ABCDEFGHIJ ABCDE', array('ABCDEFGHIJ', 'ABCDE')), 66 | array('ABCDEFGHIJ ABC ABCDE', array('ABCDEFGHIJ', 'ABC', 'ABCDE')), 67 | array('ABCDEFGHIJ', array('ABCDEFGHIJ')), 68 | // This is not a range in POP3 IDs 69 | array('10:12', array('10:12')) 70 | ); 71 | } 72 | 73 | public function testPop3Sort() 74 | { 75 | $ids = new Horde_Imap_Client_Ids_Pop3(array( 76 | 'ABC', 77 | 'A', 78 | 'AC', 79 | 'AB' 80 | )); 81 | 82 | $this->assertEquals( 83 | 'ABC A AC AB', 84 | $ids->tostring_sort 85 | ); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/NumberTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NumberTest extends TestBase 29 | { 30 | protected function getTestObs() 31 | { 32 | return array( 33 | new Horde_Imap_Client_Data_Format_Number(1), 34 | new Horde_Imap_Client_Data_Format_Number('1'), 35 | /* Invalid number. */ 36 | new Horde_Imap_Client_Data_Format_Number('Foo') 37 | ); 38 | } 39 | 40 | /** 41 | * @dataProvider stringRepresentationProvider 42 | */ 43 | public function testStringRepresentation($ob, $expected) 44 | { 45 | $this->assertEquals( 46 | $expected, 47 | strval($ob) 48 | ); 49 | } 50 | 51 | public function stringRepresentationProvider() 52 | { 53 | return $this->createProviderArray(array( 54 | '1', 55 | '1', 56 | '0' 57 | )); 58 | } 59 | 60 | /** 61 | * @dataProvider stringRepresentationProvider 62 | */ 63 | public function testEscape($ob, $expected) 64 | { 65 | $this->assertEquals( 66 | $expected, 67 | $ob->escape() 68 | ); 69 | } 70 | 71 | /** 72 | * @dataProvider verifyProvider 73 | */ 74 | public function testVerify($ob, $expected) 75 | { 76 | if ($expected) { 77 | $this->expectException('Horde_Imap_Client_Data_Format_Exception'); 78 | } 79 | 80 | $ob->verify(); 81 | 82 | $this->markTestSkipped('Horde\Imap\Client\Data\Format\NumberTest::testVerify - No Exception should be thrown here. '); 83 | } 84 | 85 | public function verifyProvider() 86 | { 87 | return $this->createProviderArray(array( 88 | false, 89 | false, 90 | true 91 | )); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: 10 | - master 11 | - maintaina-composerfixed 12 | - FRAMEWORK_6_0 13 | pull_request: 14 | branches: 15 | - master 16 | - maintaina-composerfixed 17 | - FRAMEWORK_6_0 18 | 19 | 20 | # Allows you to run this workflow manually from the Actions tab 21 | workflow_dispatch: 22 | 23 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 24 | jobs: 25 | run: 26 | runs-on: ${{ matrix.operating-system }} 27 | strategy: 28 | matrix: 29 | operating-system: ['ubuntu-20.04'] 30 | php-versions: ['7.4', '8.0', 'latest'] 31 | phpunit-versions: ['latest', '9.5'] 32 | steps: 33 | - name: Setup github ssh key 34 | run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts 35 | - name: Checkout 36 | uses: actions/checkout@v2 37 | 38 | - name: Setup PHP 39 | uses: shivammathur/setup-php@v2 40 | with: 41 | php-version: ${{ matrix.php-versions }} 42 | extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter 43 | ini-values: post_max_size=512M, max_execution_time=360 44 | coverage: xdebug 45 | tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2 46 | - name: Setup Github Token as composer credential 47 | run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} 48 | - name: Install horde/test dependency and other dependencies 49 | run: | 50 | ## For unclear reasons, github action fails randomly if we do not install before we require. 51 | COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install 52 | COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer require --dev horde/test dev-FRAMEWORK_6_0 horde/log dev-FRAMEWORK_6_0 53 | - name: install horde/db ^3 54 | run: composer require horde/db ^3 55 | - name: install horde/cli ^3 56 | run: composer require horde/cli ^3 57 | - name: install horde/cache ^3 58 | run: composer require horde/cache ^3 59 | - name: install horde/hashtable ^2 60 | run: composer require horde/hashtable ^2 61 | - name: install horde/pack ^2 62 | run: composer require horde/pack ^2 63 | - name: run phpunit 64 | run: phpunit --bootstrap test/Horde/Imap/Client/bootstrap.php test/Horde/Imap/Client/ 65 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/DateTimeTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class DateTimeTest extends TestCase 30 | { 31 | public function provider() 32 | { 33 | return array( 34 | // Bug #5715 35 | array('12 Sep 2007 15:49:12 UT', 1189612152), 36 | // Bug #9847 37 | array('Fri, 06 Oct 2006 12:15:13 +0100 (GMT+01:00)', 1160133313), 38 | // Bug #13114; This should resolve to 4/13 8:04:48pm UTC of the 39 | // current year. 40 | array('Apr 13 20:4:48', gmmktime(20, 4, 48, 4, 13)), 41 | // Bad date input 42 | array('This is a bad date', 0), 43 | // Bug #14381 44 | array('Thu, 1 Aug 2013 20:22:47 0000', 1375388567) 45 | ); 46 | } 47 | 48 | /** 49 | * @dataProvider provider 50 | */ 51 | public function testDateTimeParsing($date, $expected) 52 | { 53 | $ob = new Horde_Imap_Client_DateTime($date); 54 | 55 | $this->assertEquals( 56 | $expected, 57 | intval(strval($ob)) 58 | ); 59 | } 60 | 61 | public function testClone() 62 | { 63 | $ob = new Horde_Imap_Client_DateTime('12 Sep 2007 15:49:12 UTC'); 64 | 65 | $ob2 = clone $ob; 66 | 67 | $ob2->modify('+1 minute'); 68 | 69 | $this->assertEquals( 70 | 1189612152, 71 | intval(strval($ob)) 72 | ); 73 | 74 | $this->assertEquals( 75 | 1189612152 + 60, 76 | intval(strval($ob2)) 77 | ); 78 | } 79 | 80 | public function testSerialize() 81 | { 82 | $ob = new Horde_Imap_Client_DateTime('12 Sep 2007 15:49:12 UTC'); 83 | 84 | $ob2 = unserialize(serialize($ob)); 85 | 86 | $this->assertEquals( 87 | 1189612152, 88 | intval(strval($ob2)) 89 | ); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Utf7ConvertTest.php: -------------------------------------------------------------------------------- 1 | UTF-8 conversions. 20 | * 21 | * @author Michael Slusarz 22 | * @category Horde 23 | * @copyright 2011-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class Utf7ConvertTest extends TestCase 30 | { 31 | public static function setUpBeforeClass(): void 32 | { 33 | require_once __DIR__ . '/Stub/Utf7imap.php'; 34 | } 35 | 36 | /** 37 | * @dataProvider conversionProvider 38 | * @requires extension mbstring 39 | */ 40 | public function testConversionWithMbstring($orig, $expected = null) 41 | { 42 | Utf7imap::setMbstring(true); 43 | 44 | $this->_testConversion($orig, $expected); 45 | } 46 | 47 | /** 48 | * @dataProvider conversionProvider 49 | */ 50 | public function testConversionWithoutMbstring($orig, $expected = null) 51 | { 52 | Utf7imap::setMbstring(false); 53 | 54 | $this->_testConversion($orig, $expected); 55 | } 56 | 57 | protected function _testConversion($orig, $expected) 58 | { 59 | $utf7_imap = Utf7imap::Utf8ToUtf7Imap( 60 | $orig, 61 | !is_null($expected) 62 | ); 63 | 64 | $this->assertEquals( 65 | $expected ?: $orig, 66 | $utf7_imap 67 | ); 68 | 69 | if ($expected) { 70 | $utf8 = Utf7imap::Utf7ImapToUtf8($utf7_imap); 71 | $this->assertEquals( 72 | $orig, 73 | $utf8 74 | ); 75 | } 76 | } 77 | 78 | public function conversionProvider() 79 | { 80 | return array( 81 | array('Envoyé', 'Envoy&AOk-'), 82 | array('Töst-', 'T&APY-st-'), 83 | array('&', '&-'), 84 | array('&-'), 85 | array('Envoy&AOk-'), 86 | array('T&APY-st-'), 87 | // Bug #10133 88 | array('Entw&APw-rfe'), 89 | // Bug #10093 90 | array('Foo&Bar-2011', 'Foo&-Bar-2011') 91 | ); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Exception/ServerResponse.php: -------------------------------------------------------------------------------- 1 | 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 | * @property-read string $command The command that caused the BAD/NO error 24 | * status. 25 | * @property-read array $resp_data The response data array. 26 | * @property-read integer $status Server error status. 27 | */ 28 | class Horde_Imap_Client_Exception_ServerResponse extends Horde_Imap_Client_Exception 29 | { 30 | /** 31 | * Pipeline object. 32 | * 33 | * @var Horde_Imap_Client_Interaction_Pipeline 34 | */ 35 | protected $_pipeline; 36 | 37 | /** 38 | * Server response object. 39 | * 40 | * @var Horde_Imap_Client_Interaction_Server 41 | */ 42 | protected $_server; 43 | 44 | /** 45 | * Constructor. 46 | * 47 | * @param string|null $msg Error message. 48 | * @param integer $code Error code. 49 | * @param Horde_Imap_Client_Interaction_Server $server Server ob. 50 | * @param Horde_Imap_Client_Interaction_Pipeline $pipeline Pipeline ob. 51 | */ 52 | public function __construct( 53 | $msg, 54 | $code, 55 | Horde_Imap_Client_Interaction_Server $server, 56 | Horde_Imap_Client_Interaction_Pipeline $pipeline 57 | ) 58 | { 59 | $this->details = strval($server->token); 60 | 61 | $this->_pipeline = $pipeline; 62 | $this->_server = $server; 63 | 64 | parent::__construct($msg, $code); 65 | } 66 | 67 | /** 68 | */ 69 | public function __get($name) 70 | { 71 | switch ($name) { 72 | case 'command': 73 | return ($this->_server instanceof Horde_Imap_Client_Interaction_Server_Tagged) 74 | ? $this->_pipeline->getCmd($this->_server->tag)->getCommand() 75 | : null; 76 | 77 | case 'resp_data': 78 | return $this->_pipeline->data; 79 | 80 | case 'status': 81 | return $this->_server->status; 82 | 83 | default: 84 | return parent::__get($name); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/SearchCharsetUtf8Test.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class SearchCharsetUtf8Test extends TestCase 30 | { 31 | public function testQuery() 32 | { 33 | $s = new Horde_Imap_Client_Data_SearchCharset_Utf8(); 34 | $s->setValid('ISO-8859-1', false); 35 | 36 | $this->assertTrue($s->query('UTF-8', true)); 37 | $this->assertTrue($s->query('US-ASCII', true)); 38 | $this->assertFalse($s->query('iso-8859-1', true)); 39 | } 40 | 41 | public function testRemoval() 42 | { 43 | $s = new Horde_Imap_Client_Data_SearchCharset_Utf8(); 44 | $s->setValid('UTF-8'); 45 | 46 | $this->assertTrue($s->query('UTF-8', true)); 47 | 48 | $s->setValid('utf-8', false); 49 | 50 | $this->assertTrue($s->query('UTF-8', true)); 51 | } 52 | 53 | public function testCharsetsProperty() 54 | { 55 | $s = new Horde_Imap_Client_Data_SearchCharset_Utf8(); 56 | $s->setValid('UTF-8'); 57 | $s->setValid('UTF-8'); 58 | 59 | $this->assertEquals( 60 | array('US-ASCII', 'UTF-8'), 61 | $s->charsets 62 | ); 63 | } 64 | 65 | public function testObserver() 66 | { 67 | $s = new Horde_Imap_Client_Data_SearchCharset_Utf8(); 68 | 69 | $mock = $this->getMockBuilder('SplObserver') 70 | ->getMock(); 71 | $mock->expects($this->never()) 72 | ->method('update') 73 | ->with($this->equalTo($s)); 74 | $s->attach($mock); 75 | 76 | $s->setValid('utf-8'); 77 | /* This should be ignored. */ 78 | $s->setValid('UTF-8'); 79 | } 80 | 81 | public function testSerialize() 82 | { 83 | $s = new Horde_Imap_Client_Data_SearchCharset_Utf8(); 84 | 85 | $s_copy = unserialize(serialize($s)); 86 | 87 | $s_copy->query('UTF-8', true); 88 | 89 | $this->markTestIncomplete(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/Mailbox.php: -------------------------------------------------------------------------------- 1 | 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_Mailbox 24 | extends Horde_Imap_Client_Data_Format_Astring 25 | { 26 | /** 27 | * Mailbox encoding. 28 | * 29 | * @var string 30 | */ 31 | protected $_encoding = 'utf7imap'; 32 | 33 | /** 34 | * Mailbox object. 35 | * 36 | * @var Horde_Imap_Client_Mailbox 37 | */ 38 | protected $_mailbox; 39 | 40 | /** 41 | * @param mixed $data Either a mailbox object or a UTF-8 mailbox name. 42 | */ 43 | public function __construct($data) 44 | { 45 | $this->_mailbox = Horde_Imap_Client_Mailbox::get($data); 46 | 47 | parent::__construct($this->_mailbox->{$this->_encoding}); 48 | } 49 | 50 | /** 51 | */ 52 | public function __toString() 53 | { 54 | return strval($this->_mailbox); 55 | } 56 | 57 | /** 58 | */ 59 | public function getData() 60 | { 61 | return $this->_mailbox; 62 | } 63 | 64 | /** 65 | * @throws Horde_Imap_Client_Exception 66 | */ 67 | public function binary() 68 | { 69 | if (parent::binary()) { 70 | // Mailbox data can NEVER be sent as binary. 71 | /* @todo: Disable until Horde_Imap_Client 3.0 */ 72 | // throw new Horde_Imap_Client_Exception( 73 | // 'Client error: can not send mailbox to IMAP server as binary data.' 74 | // ); 75 | 76 | // Temporary fix: send a blank mailbox string. 77 | $this->_mailbox = Horde_Imap_Client_Mailbox::get(''); 78 | } 79 | 80 | return false; 81 | } 82 | 83 | /** 84 | */ 85 | public function length() 86 | { 87 | return strlen($this->_mailbox->{$this->_encoding}); 88 | } 89 | 90 | /** 91 | */ 92 | public function getStream() 93 | { 94 | $stream = new Horde_Stream_Temp(); 95 | $stream->add($this->_mailbox->{$this->_encoding}); 96 | return $stream; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Interaction/CommandTest.php: -------------------------------------------------------------------------------- 1 | 25 | * @category Horde 26 | * @copyright 2014-2016 Horde LLC 27 | * @ignore 28 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 29 | * @package Imap_Client 30 | * @subpackage UnitTests 31 | */ 32 | class CommandTest extends TestCase 33 | { 34 | /** 35 | * @dataProvider continuationCheckProvider 36 | */ 37 | public function testContinuationCheck($command, $result) 38 | { 39 | $this->assertEquals( 40 | $result, 41 | $command->continuation 42 | ); 43 | } 44 | 45 | public function continuationCheckProvider() 46 | { 47 | $out = array(); 48 | 49 | $cmd = new Horde_Imap_Client_Interaction_Command('FOO', '1'); 50 | $cmd->add(array( 51 | 'FOO', 52 | 'BAR' 53 | )); 54 | 55 | $out[] = array($cmd, false); 56 | 57 | $cmd = clone $cmd; 58 | $cmd->add( 59 | new Horde_Imap_Client_Interaction_Command_Continuation(function() {}) 60 | ); 61 | 62 | $out[] = array($cmd, true); 63 | 64 | $cmd = new Horde_Imap_Client_Interaction_Command('FOO', '1'); 65 | $cmd->add(array( 66 | 'FOO', 67 | array( 68 | 'BAR' 69 | ), 70 | new Horde_Imap_Client_Data_Format_List(array( 71 | 'BAR' 72 | )) 73 | )); 74 | 75 | $out[] = array($cmd, false); 76 | 77 | $cmd = new Horde_Imap_Client_Interaction_Command('FOO', '1'); 78 | $cmd->add(array( 79 | 'FOO', 80 | array( 81 | 'BAR', 82 | array( 83 | 'BAZ', 84 | array( 85 | new Horde_Imap_Client_Data_Format_String_Nonascii('Envoyé') 86 | ) 87 | ) 88 | ) 89 | )); 90 | 91 | $out[] = array($cmd, true); 92 | 93 | return $out; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Base/Alerts.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.24.0 23 | */ 24 | class Horde_Imap_Client_Base_Alerts 25 | implements SplSubject 26 | { 27 | /** 28 | * Alert data. 29 | * 30 | * @var object 31 | */ 32 | protected $_alert; 33 | 34 | /** 35 | * Observers. 36 | * 37 | * @var array 38 | */ 39 | protected $_observers = array(); 40 | 41 | /** 42 | * Add an alert. 43 | * 44 | * @param string $alert The alert string. 45 | * @param string $type The alert type. 46 | */ 47 | public function add($alert, $type = null) 48 | { 49 | $this->_alert = new stdClass; 50 | $this->_alert->alert = $alert; 51 | if (!is_null($type)) { 52 | $this->_alert->type = $type; 53 | } 54 | 55 | $this->notify(); 56 | } 57 | 58 | /** 59 | * Returns the last alert received. 60 | * 61 | * @return object Alert information. Object with these properties: 62 | *
 63 |      *   - alert: (string) Alert string.
 64 |      *   - type: (string) [OPTIONAL] Alert type.
 65 |      * 
66 | */ 67 | public function getLast() 68 | { 69 | return $this->_alert; 70 | } 71 | 72 | /* SplSubject methods. */ 73 | 74 | /** 75 | */ 76 | #[ReturnTypeWillChange] 77 | public function attach(SplObserver $observer) 78 | { 79 | $this->detach($observer); 80 | $this->_observers[] = $observer; 81 | } 82 | 83 | /** 84 | */ 85 | #[ReturnTypeWillChange] 86 | public function detach(SplObserver $observer) 87 | { 88 | if (($key = array_search($observer, $this->_observers, true)) !== false) { 89 | unset($this->_observers[$key]); 90 | } 91 | } 92 | 93 | /** 94 | * Notification is triggered internally whenever the object's internal 95 | * data storage is altered. 96 | */ 97 | #[ReturnTypeWillChange] 98 | public function notify() 99 | { 100 | foreach ($this->_observers as $val) { 101 | $val->update($this); 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/NstringTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class NstringTest extends TestBase 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_Nstring'; 31 | 32 | protected function getTestObs() 33 | { 34 | return array( 35 | new $this->cname('Foo'), 36 | new $this->cname('Foo('), 37 | /* This is an invalid atom, but valid nstring. */ 38 | new $this->cname('Foo]'), 39 | new $this->cname() 40 | ); 41 | } 42 | 43 | public function stringRepresentationProvider() 44 | { 45 | return $this->createProviderArray(array( 46 | 'Foo', 47 | 'Foo(', 48 | 'Foo]', 49 | '' 50 | )); 51 | } 52 | 53 | public function escapeProvider() 54 | { 55 | return $this->createProviderArray(array( 56 | '"Foo"', 57 | '"Foo("', 58 | '"Foo]"', 59 | 'NIL' 60 | )); 61 | } 62 | 63 | public function verifyProvider() 64 | { 65 | return $this->createProviderArray(array( 66 | true, 67 | true, 68 | true, 69 | true 70 | )); 71 | } 72 | 73 | public function binaryProvider() 74 | { 75 | return $this->createProviderArray(array( 76 | false, 77 | false, 78 | false, 79 | false 80 | )); 81 | } 82 | 83 | public function literalProvider() 84 | { 85 | return $this->binaryProvider(); 86 | } 87 | 88 | public function quotedProvider() 89 | { 90 | return $this->createProviderArray(array( 91 | true, 92 | true, 93 | true, 94 | false 95 | )); 96 | } 97 | 98 | public function escapeStreamProvider() 99 | { 100 | return $this->escapeProvider(); 101 | } 102 | 103 | public function nonasciiInputProvider() 104 | { 105 | return array( 106 | array(false) 107 | ); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /.github/workflows/phpdoc.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: PHPDOC 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: 10 | - master 11 | - maintaina-composerfixed 12 | - FRAMEWORK_6_0 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | run: 19 | runs-on: ubuntu-20.04 20 | steps: 21 | - name: Setup github ssh key 22 | run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts 23 | - name: Setup uut dir 24 | run: | 25 | export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") 26 | export UUT_DIR=$(pwd) 27 | export WORK_DIR=~ 28 | export BIN_DIR="${WORK_DIR}/bin" 29 | mkdir -p $BIN_DIR 30 | git config --global user.name "PHPDOC CI Job" 31 | git config --global user.email "ci-job@maintaina.com" 32 | - name: Checkout 33 | uses: actions/checkout@v2 34 | - name: Checkout Doc Dir 35 | uses: actions/checkout@v2 36 | with: 37 | repository: maintaina/phpdoc 38 | token: ${{secrets.PHPDOC_TOKEN}} 39 | path: "phpdoc-git" 40 | - name: Setup PHP 41 | uses: shivammathur/setup-php@v2 42 | with: 43 | php-version: 7.4 44 | extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter 45 | ini-values: post_max_size=512M, max_execution_time=360 46 | coverage: xdebug 47 | tools: composer:v2 48 | - name: Setup Github Token as composer credential 49 | run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} 50 | - name: phpdocumentor run 51 | run: | 52 | export UUT_DIR=$(pwd) 53 | export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") 54 | export WORK_DIR=/home/runner/ 55 | export BIN_DIR="${WORK_DIR}/bin" 56 | wget https://phpdoc.org/phpDocumentor.phar 57 | mkdir "${WORK_DIR}/phpdoc-out" 58 | mv phpDocumentor.phar $BIN_DIR/phpdocumentor 59 | chmod +x "${BIN_DIR}/phpdocumentor" 60 | echo "Creating UUT related dir in docu repo" 61 | mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/ 62 | ## Look into any of lib, src, app (if they exist) but not test, migration, bin, locale or script dirs 63 | $BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -d $UUT_DIR/src/ -d $UUT_DIR/app/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/" 64 | cd ${UUT_DIR}/phpdoc-git 65 | git add "${GITHUB_REF##*/}/${REPO}" 66 | php indexer.php ${GITHUB_REF##*/} $REPO 67 | git add index.html index.json 68 | git commit -m "Updated phpdoc for $GITHUB_REPOSITORY (${GITHUB_REF##*/} branch) from ci" 69 | git push 70 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/AstringTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class AstringTest extends TestBase 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_Astring'; 31 | 32 | protected function getTestObs() 33 | { 34 | return array( 35 | new $this->cname('Foo'), 36 | new $this->cname('Foo('), 37 | /* This is an invalid atom, but valid (non-quoted) astring. */ 38 | new $this->cname('Foo]'), 39 | new $this->cname('') 40 | ); 41 | } 42 | 43 | public function stringRepresentationProvider() 44 | { 45 | return $this->createProviderArray(array( 46 | 'Foo', 47 | 'Foo(', 48 | 'Foo]', 49 | '' 50 | )); 51 | } 52 | 53 | public function escapeProvider() 54 | { 55 | return $this->createProviderArray(array( 56 | 'Foo', 57 | '"Foo("', 58 | 'Foo]', 59 | '""' 60 | )); 61 | } 62 | 63 | public function verifyProvider() 64 | { 65 | return $this->createProviderArray(array( 66 | true, 67 | true, 68 | true, 69 | true 70 | )); 71 | } 72 | 73 | public function binaryProvider() 74 | { 75 | return $this->createProviderArray(array( 76 | false, 77 | false, 78 | false, 79 | false 80 | )); 81 | } 82 | 83 | public function literalProvider() 84 | { 85 | return $this->binaryProvider(); 86 | } 87 | 88 | public function quotedProvider() 89 | { 90 | return $this->createProviderArray(array( 91 | false, 92 | true, 93 | false, 94 | true 95 | )); 96 | } 97 | 98 | public function escapeStreamProvider() 99 | { 100 | return $this->createProviderArray(array( 101 | '"Foo"', 102 | '"Foo("', 103 | '"Foo]"', 104 | '""' 105 | )); 106 | } 107 | 108 | public function nonasciiInputProvider() 109 | { 110 | return array( 111 | array(false) 112 | ); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Socket/Connection/Pop3.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2013-2017 Horde LLC 24 | * @internal 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | */ 28 | class Horde_Imap_Client_Socket_Connection_Pop3 29 | extends Horde_Imap_Client_Socket_Connection_Base 30 | { 31 | /** 32 | */ 33 | protected $_protocol = 'pop3'; 34 | 35 | /** 36 | * Writes data to the POP3 output stream. 37 | * 38 | * @param string $data String data. 39 | * @param boolean $debug Output line to debug? 40 | * 41 | * @throws Horde_Imap_Client_Exception 42 | */ 43 | public function write($data, $debug = true) 44 | { 45 | if (fwrite($this->_stream, $data . "\r\n") === false) { 46 | throw new Horde_Imap_Client_Exception( 47 | Horde_Imap_Client_Translation::r("Server write error."), 48 | Horde_Imap_Client_Exception::SERVER_WRITEERROR 49 | ); 50 | } 51 | 52 | if ($debug) { 53 | $this->_params['debug']->client($data); 54 | } 55 | } 56 | 57 | /** 58 | * Read data from incoming POP3 stream. 59 | * 60 | * @param integer $size UNUSED: The number of bytes to read from the 61 | * socket. 62 | * 63 | * @return string Line of data. 64 | * 65 | * @throws Horde_Imap_Client_Exception 66 | */ 67 | public function read($size = null) 68 | { 69 | if (feof($this->_stream)) { 70 | $this->close(); 71 | $this->_params['debug']->info( 72 | 'ERROR: Server closed the connection.' 73 | ); 74 | throw new Horde_Imap_Client_Exception( 75 | Horde_Imap_Client_Translation::r("Server closed the connection unexpectedly."), 76 | Horde_Imap_Client_Exception::DISCONNECT 77 | ); 78 | } 79 | 80 | if (($read = fgets($this->_stream)) === false) { 81 | $this->_params['debug']->info('ERROR: read/timeout error.'); 82 | throw new Horde_Imap_Client_Exception( 83 | Horde_Imap_Client_Translation::r("Error when communicating with the mail server."), 84 | Horde_Imap_Client_Exception::SERVER_READERROR 85 | ); 86 | } 87 | 88 | $this->_params['debug']->server(rtrim($read, "\r\n")); 89 | 90 | return $read; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/SearchCharsetTest.php: -------------------------------------------------------------------------------- 1 | 22 | * @category Horde 23 | * @copyright 2014-2016 Horde LLC 24 | * @ignore 25 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 26 | * @package Imap_Client 27 | * @subpackage UnitTests 28 | */ 29 | class SearchCharsetTest extends TestCase 30 | { 31 | public function testQuery() 32 | { 33 | $s = new Horde_Imap_Client_Data_SearchCharset(); 34 | $s->setValid('ISO-8859-1', false); 35 | 36 | $this->assertNull($s->query('UTF-8', true)); 37 | $this->assertTrue($s->query('US-ASCII', true)); 38 | $this->assertFalse($s->query('iso-8859-1', true)); 39 | } 40 | 41 | /** 42 | * @expectedException RuntimeException 43 | */ 44 | public function testQueryWithoutBaseOb() 45 | { 46 | $this->expectException('RuntimeException'); 47 | 48 | $s = new Horde_Imap_Client_Data_SearchCharset(); 49 | 50 | $s->query('UTF-8'); 51 | } 52 | 53 | public function testRemoval() 54 | { 55 | $s = new Horde_Imap_Client_Data_SearchCharset(); 56 | $s->setValid('UTF-8'); 57 | 58 | $this->assertTrue($s->query('UTF-8', true)); 59 | 60 | $s->setValid('utf-8', false); 61 | 62 | $this->assertFalse($s->query('UTF-8', true)); 63 | } 64 | 65 | public function testCharsetsProperty() 66 | { 67 | $s = new Horde_Imap_Client_Data_SearchCharset(); 68 | $s->setValid('UTF-8'); 69 | $s->setValid('UTF-8'); 70 | 71 | $this->assertEquals( 72 | array('US-ASCII', 'UTF-8'), 73 | $s->charsets 74 | ); 75 | } 76 | 77 | public function testObserver() 78 | { 79 | $s = new Horde_Imap_Client_Data_SearchCharset(); 80 | 81 | $mock = $this->getMockBuilder('SplObserver') 82 | ->getMock(); 83 | $mock->expects($this->once()) 84 | ->method('update') 85 | ->with($this->equalTo($s)); 86 | $s->attach($mock); 87 | 88 | $s->setValid('utf-8'); 89 | /* This should be ignored. */ 90 | $s->setValid('UTF-8'); 91 | } 92 | 93 | public function testSerialize() 94 | { 95 | $s = new Horde_Imap_Client_Data_SearchCharset(); 96 | $s->setValid('utf-8'); 97 | 98 | $s_copy = unserialize(serialize($s)); 99 | 100 | $s_copy->query('UTF-8', true); 101 | 102 | $this->markTestIncomplete(); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /migration/Horde/Imap/Client/1_horde_imap_client_base_tables.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2013-2017 Horde LLC 20 | * @ignore 21 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 22 | * @package Imap_Client 23 | */ 24 | class HordeImapClientBaseTables extends Horde_Db_Migration_Base 25 | { 26 | public function up() 27 | { 28 | if (in_array('horde_imap_client_data', $this->tables())) { 29 | return; 30 | } 31 | 32 | $t = $this->createTable('horde_imap_client_data', array( 33 | 'autoincrementKey' => 'messageid' 34 | )); 35 | $t->column('hostspec', 'string', array( 36 | 'limit' => 255, 37 | 'null' => false 38 | )); 39 | $t->column('mailbox', 'string', array( 40 | 'limit' => 255, 41 | 'null' => false 42 | )); 43 | $t->column('modified', 'bigint'); 44 | $t->column('port', 'integer', array( 45 | 'null' => false 46 | )); 47 | $t->column('username', 'string', array( 48 | 'limit' => 255, 49 | 'null' => false 50 | )); 51 | $t->end(); 52 | 53 | $this->addIndex( 54 | 'horde_imap_client_data', 55 | array('hostspec', 'mailbox', 'port', 'username') 56 | ); 57 | 58 | $t = $this->createTable('horde_imap_client_message', array( 59 | 'autoincrementKey' => false 60 | )); 61 | $t->column('data', 'binary'); 62 | $t->column('msguid', 'string', array( 63 | 'null' => false 64 | )); 65 | $t->column('messageid', 'bigint', array( 66 | 'null' => false 67 | )); 68 | $t->end(); 69 | 70 | $this->addIndex( 71 | 'horde_imap_client_message', 72 | array('msguid', 'messageid') 73 | ); 74 | 75 | $t = $this->createTable('horde_imap_client_metadata', array( 76 | 'autoincrementKey' => false 77 | )); 78 | $t->column('data', 'binary'); 79 | $t->column('field', 'string', array( 80 | 'null' => false 81 | )); 82 | $t->column('messageid', 'bigint', array( 83 | 'null' => false 84 | )); 85 | $t->end(); 86 | 87 | $this->addIndex( 88 | 'horde_imap_client_metadata', 89 | array('messageid') 90 | ); 91 | } 92 | 93 | public function down() 94 | { 95 | $this->dropTable('horde_imap_client_data'); 96 | $this->dropTable('horde_imap_client_message'); 97 | $this->dropTable('horde_imap_client_metadata'); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Stub/Socket.php: -------------------------------------------------------------------------------- 1 | 25 | * @category Horde 26 | * @copyright 2011-2016 Horde LLC 27 | * @ignore 28 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 29 | * @package Imap_Client 30 | * @subpackage UnitTests 31 | */ 32 | class Socket extends Horde_Imap_Client_Socket 33 | { 34 | public $fetch_results; 35 | 36 | public function getThreadSort($data) 37 | { 38 | return new Horde_Imap_Client_Data_Thread($this->doServerResponse($this->_pipeline(), $data)->data['threadparse'], 'uid'); 39 | } 40 | 41 | public function parseNamespace($data) 42 | { 43 | return $this->doServerResponse($this->_pipeline(), $data)->data['namespace']; 44 | } 45 | 46 | public function parseACL($data) 47 | { 48 | return $this->doServerResponse($this->_pipeline(), $data)->data['getacl']; 49 | } 50 | 51 | public function parseMyACLRights($data) 52 | { 53 | return $this->doServerResponse($this->_pipeline(), $data)->data['myrights']; 54 | } 55 | 56 | public function parseListRights($data) 57 | { 58 | return $this->doServerResponse($this->_pipeline(), $data)->data['listaclrights']; 59 | } 60 | 61 | /** 62 | * @param array $data Options: 63 | * - results: (Horde_Imap_Client_Fetch_Results) 64 | */ 65 | public function parseFetch($data, array $opts = array()) 66 | { 67 | $pipeline = $this->_pipeline(); 68 | if (isset($opts['results'])) { 69 | $pipeline->fetch = $opts['results']; 70 | } 71 | $pipeline->data['modseqs_nouid'] = array(); 72 | 73 | return $this->doServerResponse($pipeline, $data); 74 | } 75 | 76 | public function doServerResponse($pipeline, $data) 77 | { 78 | $server = Horde_Imap_Client_Interaction_Server::create( 79 | new Horde_Imap_Client_Tokenize($data) 80 | ); 81 | $this->_serverResponse($pipeline, $server); 82 | return $pipeline; 83 | } 84 | 85 | public function doResponseCode($data) 86 | { 87 | $server = Horde_Imap_Client_Interaction_Server::create( 88 | new Horde_Imap_Client_Tokenize($data) 89 | ); 90 | $this->_responseCode($this->_pipeline(), $server); 91 | } 92 | 93 | public function pipeline($cmd = null) 94 | { 95 | return $this->_pipeline($cmd); 96 | } 97 | 98 | public function fetch($mailbox, $query, array $options = array()) 99 | { 100 | return $this->fetch_results; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/StringTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class StringTest extends TestBase 29 | { 30 | protected $cname = 'Horde_Imap_Client_Data_Format_String'; 31 | 32 | protected function getTestObs() 33 | { 34 | return array( 35 | new $this->cname('Foo'), 36 | new $this->cname('Foo('), 37 | /* This is an invalid atom, but valid string. */ 38 | new $this->cname('Foo]'), 39 | /* This string requires a literal. */ 40 | new $this->cname("Foo\n]"), 41 | /* This string requires a binary literal. */ 42 | new $this->cname("12\x00\n3") 43 | ); 44 | } 45 | 46 | public function stringRepresentationProvider() 47 | { 48 | return $this->createProviderArray(array( 49 | 'Foo', 50 | 'Foo(', 51 | 'Foo]', 52 | "Foo\n]", 53 | "12\x00\n3" 54 | )); 55 | } 56 | 57 | public function escapeProvider() 58 | { 59 | return $this->createProviderArray(array( 60 | '"Foo"', 61 | '"Foo("', 62 | '"Foo]"', 63 | false, 64 | false 65 | )); 66 | } 67 | 68 | public function verifyProvider() 69 | { 70 | return $this->createProviderArray(array( 71 | true, 72 | true, 73 | true, 74 | true, 75 | true 76 | )); 77 | } 78 | 79 | public function binaryProvider() 80 | { 81 | return $this->createProviderArray(array( 82 | false, 83 | false, 84 | false, 85 | false, 86 | true 87 | )); 88 | } 89 | 90 | public function literalProvider() 91 | { 92 | return $this->createProviderArray(array( 93 | false, 94 | false, 95 | false, 96 | true, 97 | true 98 | )); 99 | } 100 | 101 | public function quotedProvider() 102 | { 103 | return $this->createProviderArray(array( 104 | true, 105 | true, 106 | true, 107 | false, 108 | false 109 | )); 110 | } 111 | 112 | public function escapeStreamProvider() 113 | { 114 | return $this->escapeProvider(); 115 | } 116 | 117 | public function nonasciiInputProvider() 118 | { 119 | return array( 120 | array(false) 121 | ); 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Mailbox/MailboxUtf8Test.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2014-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class MailboxUtf8Test extends TestBase 28 | { 29 | protected $cname = 'Horde_Imap_Client_Data_Format_Mailbox_Utf8'; 30 | 31 | public function stringRepresentationProvider() 32 | { 33 | return array( 34 | array('Foo', 'Foo'), 35 | array('Foo(', 'Foo('), 36 | array('Foo%Bar', 'Foo%Bar'), 37 | array('Foo*Bar', 'Foo*Bar'), 38 | array('Envoyé', 'Envoyé') 39 | ); 40 | } 41 | 42 | public function escapeProvider() 43 | { 44 | return array( 45 | array('Foo', 'Foo'), 46 | array('Foo(', '"Foo("'), 47 | array('Foo%Bar', '"Foo%Bar"'), 48 | array('Foo*Bar', '"Foo*Bar"'), 49 | array('Envoyé', '"Envoyé"') 50 | ); 51 | } 52 | 53 | public function verifyProvider() 54 | { 55 | return array( 56 | array('Foo', false), 57 | array('Foo(', false), 58 | array('Foo%Bar', false), 59 | array('Foo*Bar', false), 60 | array('Envoyé', false) 61 | ); 62 | } 63 | 64 | public function binaryProvider() 65 | { 66 | return array( 67 | array('Foo', false), 68 | array('Foo(', false), 69 | array('Foo%Bar', false), 70 | array('Foo*Bar', false), 71 | array('Envoyé', false) 72 | ); 73 | } 74 | 75 | public function literalProvider() 76 | { 77 | return array( 78 | array('Foo', false), 79 | array('Foo(', false), 80 | array('Foo%Bar', false), 81 | array('Foo*Bar', false), 82 | array('Envoyé', false) 83 | ); 84 | } 85 | 86 | public function quotedProvider() 87 | { 88 | return array( 89 | array('Foo', false), 90 | array('Foo(', true), 91 | array('Foo%Bar', true), 92 | array('Foo*Bar', true), 93 | array('Envoyé', true) 94 | ); 95 | } 96 | 97 | public function escapeStreamProvider() 98 | { 99 | return array( 100 | array('Foo', '"Foo"'), 101 | array('Foo(', '"Foo("'), 102 | array('Foo%Bar', '"Foo%Bar"'), 103 | array('Foo*Bar', '"Foo*Bar"'), 104 | array('Envoyé', '"Envoyé"') 105 | ); 106 | } 107 | 108 | public function testBadInput() 109 | { 110 | $this->expectException('Horde_Imap_Client_Data_Format_Exception'); 111 | 112 | new $this->cname("foo\1"); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Data/Format/List.php: -------------------------------------------------------------------------------- 1 | 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_List extends Horde_Imap_Client_Data_Format implements Countable, IteratorAggregate 24 | { 25 | /** 26 | * @see add() 27 | */ 28 | public function __construct($data = null) 29 | { 30 | parent::__construct(array()); 31 | 32 | if (!is_null($data)) { 33 | $this->add($data); 34 | } 35 | } 36 | 37 | /** 38 | * Add an element to the list. 39 | * 40 | * @param mixed $data The data element(s) to add. Either a 41 | * Horde_Imap_Client_Data_Format object, a string 42 | * value that will be treated as an IMAP atom, or 43 | * an array (or iterable object) of objects to add. 44 | * @param boolean $merge Merge the contents of any container objects, 45 | * instead of adding the objects themselves? 46 | * 47 | * @return Horde_Imap_Client_Data_Format_List This object to allow for 48 | * chainable calls (since 49 | * 2.10.0). 50 | */ 51 | public function add($data, $merge = false) 52 | { 53 | if (is_array($data) || ($merge && ($data instanceof Traversable))) { 54 | foreach ($data as $val) { 55 | $this->add($val); 56 | } 57 | } elseif (is_object($data)) { 58 | $this->_data[] = $data; 59 | } elseif (!is_null($data)) { 60 | $this->_data[] = new Horde_Imap_Client_Data_Format_Atom($data); 61 | } 62 | 63 | return $this; 64 | } 65 | 66 | /** 67 | */ 68 | public function __toString() 69 | { 70 | $out = ''; 71 | 72 | foreach ($this as $val) { 73 | if ($val instanceof $this) { 74 | $out .= '(' . $val->escape() . ') '; 75 | } elseif (($val instanceof Horde_Imap_Client_Data_Format_String) && 76 | $val->literal()) { 77 | /* ERROR: Requires literal output. */ 78 | return ''; 79 | } else { 80 | $out .= $val->escape() . ' '; 81 | } 82 | } 83 | 84 | return rtrim($out); 85 | } 86 | 87 | /* Countable methods. */ 88 | 89 | /** 90 | */ 91 | #[ReturnTypeWillChange] 92 | public function count() 93 | { 94 | return count($this->_data); 95 | } 96 | 97 | /* IteratorAggregate method. */ 98 | 99 | /** 100 | * Iterator loops through the data elements contained in this list. 101 | */ 102 | #[ReturnTypeWillChange] 103 | public function getIterator() 104 | { 105 | return new ArrayIterator($this->_data); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Mailbox/ListMailboxTest.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2011-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class ListMailboxTest extends TestBase 28 | { 29 | protected $cname = 'Horde_Imap_Client_Data_Format_ListMailbox'; 30 | 31 | public function stringRepresentationProvider() 32 | { 33 | return array( 34 | array('Foo', 'Foo'), 35 | array('Foo(', 'Foo('), 36 | array('Foo]', 'Foo]'), 37 | array('Foo%Bar', 'Foo%Bar'), 38 | array('Foo*Bar', 'Foo*Bar'), 39 | array('Envoyé', 'Envoyé') 40 | ); 41 | } 42 | 43 | public function escapeProvider() 44 | { 45 | return array( 46 | array('Foo', 'Foo'), 47 | array('Foo(', '"Foo("'), 48 | array('Foo]', 'Foo]'), 49 | /* Don't escape '%'. */ 50 | array('Foo%Bar', 'Foo%Bar'), 51 | /* Don't escape '*'. */ 52 | array('Foo*Bar', 'Foo*Bar'), 53 | array('Envoyé', 'Envoy&AOk-') 54 | ); 55 | } 56 | 57 | public function verifyProvider() 58 | { 59 | return array( 60 | array('Foo', false), 61 | array('Foo(', false), 62 | array('Foo]', false), 63 | array('Foo%Bar', false), 64 | array('Foo*Bar', false), 65 | array('Envoyé', false) 66 | ); 67 | } 68 | 69 | public function binaryProvider() 70 | { 71 | return array( 72 | array('Foo', false), 73 | array('Foo(', false), 74 | array('Foo]', false), 75 | array('Foo%Bar', false), 76 | array('Foo*Bar', false), 77 | array('Envoyé', false) 78 | ); 79 | } 80 | 81 | public function literalProvider() 82 | { 83 | return array( 84 | array('Foo', false), 85 | array('Foo(', false), 86 | array('Foo]', false), 87 | array('Foo%Bar', false), 88 | array('Foo*Bar', false), 89 | array('Envoyé', false) 90 | ); 91 | } 92 | 93 | public function quotedProvider() 94 | { 95 | return array( 96 | array('Foo', false), 97 | array('Foo(', true), 98 | array('Foo]', false), 99 | array('Foo%Bar', false), 100 | array('Foo*Bar', false), 101 | array('Envoyé', false) 102 | ); 103 | } 104 | 105 | public function escapeStreamProvider() 106 | { 107 | return array( 108 | array('Foo', '"Foo"'), 109 | array('Foo(', '"Foo("'), 110 | array('Foo]', '"Foo]"'), 111 | array('Foo%Bar', '"Foo%Bar"'), 112 | array('Foo*Bar', '"Foo*Bar"'), 113 | array('Envoyé', '"Envoy&AOk-"') 114 | ); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Mailbox/ListMailboxUtf8Test.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2014-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class ListMailboxUtf8Test extends TestBase 28 | { 29 | protected $cname = 'Horde_Imap_Client_Data_Format_ListMailbox_Utf8'; 30 | 31 | public function stringRepresentationProvider() 32 | { 33 | return array( 34 | array('Foo', 'Foo'), 35 | array('Foo(', 'Foo('), 36 | array('Foo]', 'Foo]'), 37 | array('Foo%Bar', 'Foo%Bar'), 38 | array('Foo*Bar', 'Foo*Bar'), 39 | array('Envoyé', 'Envoyé') 40 | ); 41 | } 42 | 43 | public function escapeProvider() 44 | { 45 | return array( 46 | array('Foo', 'Foo'), 47 | array('Foo(', '"Foo("'), 48 | array('Foo]', 'Foo]'), 49 | /* Don't escape '%'. */ 50 | array('Foo%Bar', 'Foo%Bar'), 51 | /* Don't escape '*'. */ 52 | array('Foo*Bar', 'Foo*Bar'), 53 | array('Envoyé', '"Envoyé"') 54 | ); 55 | } 56 | 57 | public function verifyProvider() 58 | { 59 | return array( 60 | array('Foo', false), 61 | array('Foo(', false), 62 | array('Foo]', false), 63 | array('Foo%Bar', false), 64 | array('Foo*Bar', false), 65 | array('Envoyé', false) 66 | ); 67 | } 68 | 69 | public function binaryProvider() 70 | { 71 | return array( 72 | array('Foo', false), 73 | array('Foo(', false), 74 | array('Foo]', false), 75 | array('Foo%Bar', false), 76 | array('Foo*Bar', false), 77 | array('Envoyé', false) 78 | ); 79 | } 80 | 81 | public function literalProvider() 82 | { 83 | return array( 84 | array('Foo', false), 85 | array('Foo(', false), 86 | array('Foo]', false), 87 | array('Foo%Bar', false), 88 | array('Foo*Bar', false), 89 | array('Envoyé', false) 90 | ); 91 | } 92 | 93 | public function quotedProvider() 94 | { 95 | return array( 96 | array('Foo', false), 97 | array('Foo(', true), 98 | array('Foo]', false), 99 | array('Foo%Bar', false), 100 | array('Foo*Bar', false), 101 | array('Envoyé', true) 102 | ); 103 | } 104 | 105 | public function escapeStreamProvider() 106 | { 107 | return array( 108 | array('Foo', '"Foo"'), 109 | array('Foo(', '"Foo("'), 110 | array('Foo]', '"Foo]"'), 111 | array('Foo%Bar', '"Foo%Bar"'), 112 | array('Foo*Bar', '"Foo*Bar"'), 113 | array('Envoyé', '"Envoyé"') 114 | ); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Live/Pop3.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2013-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class Pop3 extends Base 28 | { 29 | public static $config; 30 | 31 | public static function setUpBeforeClass() 32 | { 33 | $c = array_shift(self::$config); 34 | 35 | try { 36 | $c['client_config']['cache'] = array( 37 | 'cacheob' => new Horde_Cache( 38 | new Horde_Cache_Storage_Mock(), 39 | array('compress' => true) 40 | ) 41 | ); 42 | } catch (Exception $e) {} 43 | 44 | self::$live = new Horde_Imap_Client_Socket_Pop3( 45 | $c['client_config'] 46 | ); 47 | } 48 | 49 | /* Tests */ 50 | 51 | public function testPreLoginCommands() 52 | { 53 | $c = self::$live->capability; 54 | 55 | $this->assertInstanceOf( 56 | 'Horde_Imap_Client_Data_Capability', 57 | $c 58 | ); 59 | } 60 | 61 | /** 62 | * @depends testPreLoginCommands 63 | */ 64 | public function testLogin() 65 | { 66 | /* Throws exception on error, which will prevent all further testing 67 | * on this server. */ 68 | self::$live->login(); 69 | } 70 | 71 | /** 72 | * @depends testLogin 73 | */ 74 | public function testPostLoginCapability() 75 | { 76 | /* Re-use testPreLoginCommands(). */ 77 | $this->testPreLoginCommands(); 78 | } 79 | 80 | /** 81 | * @depends testLogin 82 | */ 83 | public function testOpenMailbox() 84 | { 85 | self::$live->openMailbox('INBOX', Horde_Imap_Client::OPEN_READONLY); 86 | self::$live->openMailbox('INBOX', Horde_Imap_Client::OPEN_READWRITE); 87 | self::$live->openMailbox('INBOX', Horde_Imap_Client::OPEN_AUTO); 88 | } 89 | 90 | /** 91 | * @depends testLogin 92 | */ 93 | public function testListMailbox() 94 | { 95 | // Listing all mailboxes (flat format). 96 | $l = self::$live->listMailboxes( 97 | '*', 98 | Horde_Imap_Client::MBOX_ALL, 99 | array('flat' => true) 100 | ); 101 | 102 | $this->assertEquals(1, count($l)); 103 | } 104 | 105 | /** 106 | * @depends testLogin 107 | */ 108 | public function testStatus() 109 | { 110 | $s = self::$live->status('INBOX', Horde_Imap_Client::STATUS_ALL); 111 | 112 | $this->assertInternalType('array', $s); 113 | 114 | $this->assertArrayHasKey('messages', $s); 115 | $this->assertArrayHasKey('recent', $s); 116 | $this->assertEquals($s['messages'], $s['recent']); 117 | $this->assertArrayHasKey('uidnext', $s); 118 | $this->assertArrayHasKey('uidvalidity', $s); 119 | $this->assertArrayHasKey('unseen', $s); 120 | $this->assertEquals(0, $s['unseen']); 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/AtomTest.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2011-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | class AtomTest extends TestBase 29 | { 30 | protected function getTestObs() 31 | { 32 | return array( 33 | new Horde_Imap_Client_Data_Format_Atom('Foo'), 34 | /* Illegal atom character. */ 35 | new Horde_Imap_Client_Data_Format_Atom('Foo('), 36 | /* This is an invalid atom, but valid (non-quoted) astring. */ 37 | new Horde_Imap_Client_Data_Format_Atom('Foo]'), 38 | new Horde_Imap_Client_Data_Format_Atom('') 39 | ); 40 | } 41 | 42 | /** 43 | * @dataProvider stringRepresentationProvider 44 | */ 45 | public function testStringRepresentation($ob, $expected) 46 | { 47 | $this->assertEquals( 48 | $expected, 49 | strval($ob) 50 | ); 51 | } 52 | 53 | public function stringRepresentationProvider() 54 | { 55 | return $this->createProviderArray(array( 56 | 'Foo', 57 | 'Foo(', 58 | 'Foo]', 59 | '', 60 | )); 61 | } 62 | 63 | /** 64 | * @dataProvider escapeProvider 65 | */ 66 | public function testEscape($ob, $expected) 67 | { 68 | $this->assertEquals( 69 | $expected, 70 | $ob->escape() 71 | ); 72 | } 73 | 74 | public function escapeProvider() 75 | { 76 | return $this->createProviderArray(array( 77 | 'Foo', 78 | 'Foo(', 79 | 'Foo]', 80 | '""', 81 | )); 82 | } 83 | 84 | /** 85 | * @dataProvider verifyProvider 86 | */ 87 | public function testVerify($ob, $expected) 88 | { 89 | if ($expected) { 90 | $this->expectException('Horde_Imap_Client_Data_Format_Exception'); 91 | } 92 | 93 | $ob->verify(); 94 | 95 | $this->markTestSkipped('Horde\Imap\Client\Data\Format\AtomTest::testVerify - No Exception should be thrown here. '); 96 | } 97 | 98 | public function verifyProvider() 99 | { 100 | return $this->createProviderArray(array( 101 | false, 102 | true, 103 | true, 104 | false 105 | )); 106 | } 107 | 108 | /** 109 | * @dataProvider stripNonAtomCharactersProvider 110 | */ 111 | public function testStripNonAtomCharacters($str, $expected) 112 | { 113 | $atom = new Horde_Imap_Client_Data_Format_Atom($str); 114 | $this->assertEquals( 115 | $expected, 116 | $atom->stripNonAtomCharacters() 117 | ); 118 | } 119 | 120 | public function stripNonAtomCharactersProvider() 121 | { 122 | return array( 123 | array('ABC123abc', 'ABC123abc'), 124 | array('A[{À*"A', 'A[A') 125 | ); 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /lib/Horde/Imap/Client/Namespace/List.php: -------------------------------------------------------------------------------- 1 | 18 | * @category Horde 19 | * @copyright 2014-2017 Horde LLC 20 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 21 | * @package Imap_Client 22 | * @since 2.21.0 23 | */ 24 | class Horde_Imap_Client_Namespace_List 25 | implements ArrayAccess, Countable, IteratorAggregate 26 | { 27 | /** 28 | * The list of namespace objects. 29 | * 30 | * @var array 31 | */ 32 | protected $_ns = array(); 33 | 34 | /** 35 | * Constructor. 36 | * 37 | * @param array $ns The list of namespace objects. 38 | */ 39 | public function __construct($ns = array()) 40 | { 41 | foreach ($ns as $val) { 42 | $this->_ns[strval($val)] = $val; 43 | } 44 | } 45 | 46 | /** 47 | * Get namespace info for a full mailbox path. 48 | * 49 | * @param string $mbox The mailbox path. 50 | * @param boolean $personal If true, will return the empty namespace only 51 | * if it is a personal namespace. 52 | * 53 | * @return mixed The Horde_Imap_Client_Data_Namespace object for the 54 | * mailbox path, or null if the path doesn't exist. 55 | */ 56 | public function getNamespace($mbox, $personal = false) 57 | { 58 | $mbox = strval($mbox); 59 | 60 | if ($ns = $this[$mbox]) { 61 | return $ns; 62 | } 63 | 64 | foreach ($this->_ns as $val) { 65 | $mbox = $mbox . $val->delimiter; 66 | if (strlen($val->name) && (strpos($mbox, $val->name) === 0)) { 67 | return $val; 68 | } 69 | } 70 | 71 | return (($ns = $this['']) && (!$personal || ($ns->type === $ns::NS_PERSONAL))) 72 | ? $ns 73 | : null; 74 | } 75 | 76 | /* ArrayAccess methods. */ 77 | 78 | /** 79 | */ 80 | #[ReturnTypeWillChange] 81 | public function offsetExists($offset) 82 | { 83 | return isset($this->_ns[strval($offset)]); 84 | } 85 | 86 | /** 87 | */ 88 | #[ReturnTypeWillChange] 89 | public function offsetGet($offset) 90 | { 91 | $offset = strval($offset); 92 | 93 | return isset($this->_ns[$offset]) 94 | ? $this->_ns[$offset] 95 | : null; 96 | } 97 | 98 | /** 99 | */ 100 | #[ReturnTypeWillChange] 101 | public function offsetSet($offset, $value) 102 | { 103 | if ($value instanceof Horde_Imap_Client_Data_Namespace) { 104 | $this->_ns[strval($value)] = $value; 105 | } 106 | } 107 | 108 | /** 109 | */ 110 | #[ReturnTypeWillChange] 111 | public function offsetUnset($offset) 112 | { 113 | unset($this->_ns[strval($offset)]); 114 | } 115 | 116 | /* Countable methods. */ 117 | 118 | /** 119 | */ 120 | #[ReturnTypeWillChange] 121 | public function count() 122 | { 123 | return count($this->_ns); 124 | } 125 | 126 | /* IteratorAggregate methods. */ 127 | 128 | /** 129 | */ 130 | #[ReturnTypeWillChange] 131 | public function getIterator() 132 | { 133 | return new ArrayIterator($this->_ns); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/Mailbox/TestBase.php: -------------------------------------------------------------------------------- 1 | 21 | * @category Horde 22 | * @copyright 2014-2016 Horde LLC 23 | * @ignore 24 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 25 | * @package Imap_Client 26 | * @subpackage UnitTests 27 | */ 28 | abstract class TestBase extends TestCase 29 | { 30 | protected $cname; 31 | 32 | /** 33 | * @dataProvider stringRepresentationProvider 34 | */ 35 | public function testStringRepresentation($mbox, $str) 36 | { 37 | $m = new $this->cname($mbox); 38 | 39 | $this->assertEquals( 40 | $str, 41 | strval($m) 42 | ); 43 | } 44 | 45 | abstract public function stringRepresentationProvider(); 46 | 47 | /** 48 | * @dataProvider escapeProvider 49 | */ 50 | public function testEscape($mbox, $str) 51 | { 52 | $m = new $this->cname($mbox); 53 | 54 | $this->assertEquals( 55 | $str, 56 | $m->escape() 57 | ); 58 | } 59 | 60 | abstract public function escapeProvider(); 61 | 62 | /** 63 | * @dataProvider verifyProvider 64 | */ 65 | public function testVerify($mbox, $exception) 66 | { 67 | if ($exception) { 68 | $this->expectException('Exception'); 69 | } 70 | 71 | $m = new $this->cname($mbox); 72 | 73 | $this->markTestSkipped('Horde\Imap\Client\Data\Format\Mailbox\MailboxUtf8Test::testVerify - No Exception should be thrown here. '); 74 | } 75 | 76 | abstract public function verifyProvider(); 77 | 78 | /** 79 | * @dataProvider binaryProvider 80 | */ 81 | public function testBinary($mbox, $expected) 82 | { 83 | $m = new $this->cname($mbox); 84 | 85 | if ($expected) { 86 | $this->assertTrue($m->binary()); 87 | } else { 88 | $this->assertFalse($m->binary()); 89 | } 90 | } 91 | 92 | abstract public function binaryProvider(); 93 | 94 | /** 95 | * @dataProvider literalProvider 96 | */ 97 | public function testLiteral($mbox, $expected) 98 | { 99 | $m = new $this->cname($mbox); 100 | 101 | if ($expected) { 102 | $this->assertTrue($m->literal()); 103 | } else { 104 | $this->assertFalse($m->literal()); 105 | } 106 | } 107 | 108 | abstract public function literalProvider(); 109 | 110 | /** 111 | * @dataProvider quotedProvider 112 | */ 113 | public function testQuoted($mbox, $expected) 114 | { 115 | $m = new $this->cname($mbox); 116 | 117 | if ($expected) { 118 | $this->assertTrue($m->quoted()); 119 | } else { 120 | $this->assertFalse($m->quoted()); 121 | } 122 | } 123 | 124 | abstract public function quotedProvider(); 125 | 126 | /** 127 | * @dataProvider escapeStreamProvider 128 | */ 129 | public function testEscapeStream($mbox, $expected) 130 | { 131 | $m = new $this->cname($mbox); 132 | 133 | $this->assertEquals( 134 | $expected, 135 | stream_get_contents($m->escapeStream(), -1, 0) 136 | ); 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Url/Pop3Test.php: -------------------------------------------------------------------------------- 1 | 20 | * @category Horde 21 | * @copyright 2014-2016 Horde LLC 22 | * @ignore 23 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 24 | * @package Imap_Client 25 | * @subpackage UnitTests 26 | */ 27 | class Pop3Test extends TestBase 28 | { 29 | protected $classname = 'Horde_Imap_Client_Url_Pop3'; 30 | protected $host = 'host'; 31 | protected $protocol = 'pop'; 32 | 33 | public function testUrlProvider() 34 | { 35 | $this->markTestIncomplete(); 36 | 37 | return array( 38 | array( 39 | 'pop://test.example.com/', 40 | null, 41 | array( 42 | 'host' => 'test.example.com', 43 | 'port' => 110 44 | ) 45 | ), 46 | array( 47 | 'pop://test.example.com:110/', 48 | 'pop://test.example.com/', 49 | array( 50 | 'host' => 'test.example.com', 51 | 'port' => 110 52 | ) 53 | ), 54 | array( 55 | 'pop://testuser@test.example.com/', 56 | null, 57 | array( 58 | 'host' => 'test.example.com', 59 | 'port' => 110, 60 | 'username' => 'testuser' 61 | ) 62 | ), 63 | // This is the default port for IMAP, not POP3 64 | array( 65 | 'pop://testuser@test.example.com:143/', 66 | null, 67 | array( 68 | 'host' => 'test.example.com', 69 | 'port' => 143, 70 | 'username' => 'testuser' 71 | ) 72 | ), 73 | array( 74 | 'pop://testuser;AUTH=*@test.example.com:110/', 75 | 'pop://testuser@test.example.com/', 76 | array( 77 | 'auth' => null, 78 | 'host' => 'test.example.com', 79 | 'port' => 110, 80 | 'username' => 'testuser' 81 | ) 82 | ), 83 | array( 84 | 'pop://testuser;AUTH=PLAIN@test.example.com/', 85 | null, 86 | array( 87 | 'host' => 'test.example.com', 88 | 'port' => 110, 89 | 'username' => 'testuser', 90 | 'auth' => 'PLAIN' 91 | ) 92 | ), 93 | // Ignore everything after the port. 94 | array( 95 | 'pop://test.example.com:110/INBOX.Quarant%26AOQ-ne;UIDVALIDITY=1240054819/;UID=39193/;SECTION=HEADER', 96 | 'pop://test.example.com/', 97 | array( 98 | 'host' => 'test.example.com', 99 | 'port' => 110, 100 | 'section' => '', 101 | 'uid' => '', 102 | 'uidvalidity' => '', 103 | 'mailbox' => '' 104 | ) 105 | ) 106 | ); 107 | } 108 | 109 | public function serializeProvider() 110 | { 111 | return array( 112 | array('pop://test.example.com/') 113 | ); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Namespace/ListTest.php: -------------------------------------------------------------------------------- 1 | 23 | * @category Horde 24 | * @copyright 2014-2016 Horde LLC 25 | * @ignore 26 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 27 | * @package Imap_Client 28 | * @subpackage UnitTests 29 | */ 30 | class ListTest extends TestCase 31 | { 32 | private $ob; 33 | 34 | public function setUp(): void 35 | { 36 | $this->ob = new Horde_Imap_Client_Namespace_List(); 37 | 38 | $ob2 = new Horde_Imap_Client_Data_Namespace(); 39 | $ob2->delimiter = '.'; 40 | $ob2->type = $ob2::NS_SHARED; 41 | $this->ob[''] = $ob2; 42 | 43 | $ob3 = new Horde_Imap_Client_Data_Namespace(); 44 | $ob3->delimiter = '.'; 45 | $ob3->hidden = true; 46 | $ob3->name = 'foo'; 47 | $this->ob['foo'] = $ob3; 48 | } 49 | 50 | /** 51 | * @dataProvider arrayProvider 52 | */ 53 | public function testArrayAccess($name, $exists = true) 54 | { 55 | if ($exists) { 56 | $this->assertTrue(isset($this->ob[$name])); 57 | $this->assertInstanceof( 58 | 'Horde_Imap_Client_Data_Namespace', 59 | $this->ob[$name] 60 | ); 61 | } else { 62 | $this->assertFalse(isset($this->ob[$name])); 63 | $this->assertNull($this->ob[$name]); 64 | } 65 | } 66 | 67 | /** 68 | */ 69 | public function testCountable() 70 | { 71 | $this->assertEquals( 72 | 2, 73 | count($this->ob) 74 | ); 75 | } 76 | 77 | /** 78 | */ 79 | public function testIterator() 80 | { 81 | foreach ($this->ob as $val) { 82 | $this->assertInstanceof( 83 | 'Horde_Imap_Client_Data_Namespace', 84 | $val 85 | ); 86 | } 87 | } 88 | 89 | /** 90 | */ 91 | public function testSerialize() 92 | { 93 | $ob2 = unserialize(serialize($this->ob)); 94 | 95 | $this->assertEquals( 96 | 2, 97 | count($this->ob) 98 | ); 99 | } 100 | 101 | /** 102 | * @dataProvider getNamespaceProvider 103 | */ 104 | public function testGetNamespace($mbox, $personal, $expected) 105 | { 106 | if (is_null($expected)) { 107 | $this->assertNull($this->ob->getNamespace($mbox, $personal)); 108 | } else { 109 | $this->assertEquals( 110 | $expected, 111 | strval($this->ob->getNamespace($mbox, $personal)) 112 | ); 113 | } 114 | } 115 | 116 | /** 117 | */ 118 | public function arrayProvider() 119 | { 120 | return array( 121 | array(''), 122 | array('foo'), 123 | array('bar', false) 124 | ); 125 | } 126 | 127 | /** 128 | */ 129 | public function getNamespaceProvider() 130 | { 131 | return array( 132 | array('baz', false, ''), 133 | array('baz', true, null), 134 | array('foo.bar', false, 'foo'), 135 | array('foo.bar', true, 'foo'), 136 | array('baz.bar', false, ''), 137 | array('baz.bar', true, null) 138 | ); 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/AuthTest.php: -------------------------------------------------------------------------------- 1 | 23 | * @category Horde 24 | * @copyright 2011-2016 Horde LLC 25 | * @ignore 26 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 27 | * @package Imap_Client 28 | * @subpackage UnitTests 29 | 30 | */ 31 | class AuthTest extends TestCase 32 | { 33 | public static function setUpBeforeClass(): void 34 | { 35 | require_once __DIR__ . '/Stub/DigestMD5.php'; 36 | require_once __DIR__ . '/Stub/Scram.php'; 37 | } 38 | 39 | /** 40 | * @dataProvider digestMd5Provider 41 | */ 42 | public function testDigestMd5($c) 43 | { 44 | $ob = new DigestMD5( 45 | $c['user'], 46 | $c['pass'], 47 | $c['challenge'], 48 | $c['hostname'], 49 | $c['service'], 50 | $c['cnonce'] 51 | ); 52 | 53 | $this->assertEquals( 54 | $c['expected'], 55 | $ob->response 56 | ); 57 | } 58 | 59 | public function digestMd5Provider() 60 | { 61 | return array( 62 | array( 63 | // IMAP example from RFC 2831 [4] 64 | array( 65 | 'user' => 'chris', 66 | 'pass' => 'secret', 67 | 'challenge' => base64_decode('cmVhbG09ImVsd29vZC5pbm5vc29mdC5jb20iLG5vbmNlPSJPQTZNRzl0RVFHbTJoaCIscW9wPSJhdXRoIixhbGdvcml0aG09bWQ1LXNlc3MsY2hhcnNldD11dGYtOA=='), 68 | 'hostname' => 'elwood.innosoft.com', 69 | 'service' => 'imap', 70 | 'cnonce' => 'OA6MHXh6VqTrRk', 71 | 'expected' => 'd388dad90d4bbd760a152321f2143af7' 72 | ) 73 | ) 74 | ); 75 | } 76 | 77 | /** 78 | * @dataProvider scramProvider 79 | */ 80 | public function testScram($c) 81 | { 82 | $this->expectException('Horde_Imap_Client_Exception'); 83 | 84 | $ob = new Scram( 85 | $c['user'], 86 | $c['pass'], 87 | $c['hash'] 88 | ); 89 | $ob->setNonce($c['nonce']); 90 | 91 | $this->assertEquals( 92 | $c['c1'], 93 | $ob->getClientFirstMessage() 94 | ); 95 | 96 | $this->assertTrue($ob->parseServerFirstMessage($c['s1'])); 97 | 98 | $this->assertEquals( 99 | $c['c2'], 100 | $ob->getClientFinalMessage() 101 | ); 102 | 103 | $this->assertTrue($ob->parseServerFinalMessage($c['s2'])); 104 | } 105 | 106 | public function scramProvider() 107 | { 108 | return array( 109 | array( 110 | // Example from RFC 5802 [5] 111 | array( 112 | 'user' => 'user', 113 | 'pass' => 'pencil', 114 | 'hash' => 'SHA1', 115 | 'nonce' => 'fyko+d2lbbFgONRv9qkxdawL', 116 | 'c1' => 'n,,n=user,r=fyko+d2lbbFgONRv9qkxdawL', 117 | 's1' => 'r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096', 118 | 'c2' => 'c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts=', 119 | 's2' => 'v=rmF9pqV8S7suAoZWja4dJRkFsKQ=' 120 | ) 121 | ) 122 | ); 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /test/Horde/Imap/Client/Data/Format/ListTest.php: -------------------------------------------------------------------------------- 1 | 24 | * @category Horde 25 | * @copyright 2011-2016 Horde LLC 26 | * @ignore 27 | * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 28 | * @package Imap_Client 29 | * @subpackage UnitTests 30 | */ 31 | class ListTest extends TestCase 32 | { 33 | public function testBasicListFunctions() 34 | { 35 | $ob = new Horde_Imap_Client_Data_Format_List(); 36 | 37 | $this->assertEquals( 38 | 0, 39 | count($ob) 40 | ); 41 | 42 | $ob->add(new Horde_Imap_Client_Data_Format_Atom('Foo')); 43 | $ob->add(new Horde_Imap_Client_Data_Format_Atom('Bar')); 44 | $ob->add(new Horde_Imap_Client_Data_Format_String('Baz')); 45 | 46 | $this->assertEquals( 47 | 3, 48 | count($ob) 49 | ); 50 | 51 | $this->assertEquals( 52 | 'Foo Bar "Baz"', 53 | strval($ob) 54 | ); 55 | 56 | $this->assertEquals( 57 | 'Foo Bar "Baz"', 58 | $ob->escape() 59 | ); 60 | 61 | foreach ($ob as $key => $val) { 62 | switch ($key) { 63 | case 0: 64 | case 1: 65 | $this->assertEquals( 66 | 'Horde_Imap_Client_Data_Format_Atom', 67 | get_class($val) 68 | ); 69 | break; 70 | 71 | case 2: 72 | $this->assertEquals( 73 | 'Horde_Imap_Client_Data_Format_String', 74 | get_class($val) 75 | ); 76 | break; 77 | } 78 | } 79 | 80 | } 81 | 82 | public function testAdvancedListFunctions() 83 | { 84 | $ob = new Horde_Imap_Client_Data_Format_List('Foo'); 85 | 86 | $this->assertEquals( 87 | 1, 88 | count($ob) 89 | ); 90 | 91 | $ob_array = iterator_to_array($ob); 92 | $this->assertEquals( 93 | 'Horde_Imap_Client_Data_Format_Atom', 94 | get_class(reset($ob_array)) 95 | ); 96 | 97 | $ob->add(array( 98 | 'Foo', 99 | new Horde_Imap_Client_Data_Format_List(array('Bar')) 100 | )); 101 | 102 | $this->assertEquals( 103 | 3, 104 | count($ob) 105 | ); 106 | 107 | $this->assertEquals( 108 | 'Foo Foo (Bar)', 109 | $ob->escape() 110 | ); 111 | 112 | $ob = new Horde_Imap_Client_Data_Format_List(array( 113 | 'Foo', 114 | new Horde_Imap_Client_Data_Format_List(array( 115 | 'Foo1' 116 | )), 117 | 'Bar', 118 | new Horde_Imap_Client_Data_Format_List(array( 119 | new Horde_Imap_Client_Data_Format_String('Bar1'), 120 | new Horde_Imap_Client_Data_Format_List(array( 121 | 'Baz' 122 | )) 123 | )) 124 | )); 125 | 126 | $this->assertEquals( 127 | 4, 128 | count($ob) 129 | ); 130 | 131 | $this->assertEquals( 132 | 'Foo (Foo1) Bar ("Bar1" (Baz))', 133 | $ob->escape() 134 | ); 135 | } 136 | 137 | } 138 | --------------------------------------------------------------------------------