From 4956b59ea27923b70668e5b2460171fea89bef7b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 20 Apr 2010 15:03:47 -0600 Subject: [PATCH] Add Horde_Imap_Client_Utils::stripNonAtomChars() --- framework/Imap_Client/lib/Horde/Imap/Client/Utils.php | 14 ++++++++++++++ framework/Imap_Client/package.xml | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php b/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php index a11588dae..7d8dff53c 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Utils.php @@ -173,6 +173,20 @@ class Horde_Imap_Client_Utils } /** + * Given a string, will strip out any characters that are not allowed in + * the IMAP 'atom' definition (RFC 3501 [9]). + * + * @param string $str An ASCII string. + * + * @return string The string with the disallowed atom characters stripped + * out. + */ + public function stripNonAtomChars($str) + { + return str_replace(array('(', ')', '{', ' ', '%', '*', '"', '\\', ']'), '', preg_replace('/[\x00-\x1f\x7f]/', '', $str)); + } + + /** * Return the "base subject" defined in RFC 5256 [2.1]. * * @param string $str The original subject string. diff --git a/framework/Imap_Client/package.xml b/framework/Imap_Client/package.xml index 7dcb47000..b23816ccd 100644 --- a/framework/Imap_Client/package.xml +++ b/framework/Imap_Client/package.xml @@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha LGPL - * Add sequence sort (numeric sort by UID/sequence number). + * Add Horde_Imap_Client_Utils::stripNonAtomChars(). + * Add sequence sort (numeric sort by UID/sequence number). * Add ability to disable server capabilities. * Add Horde_Imap_Client_Base::parseCacheId(). * Added STATUS_LASTMODSEQ and STATUS_LASTMODSEQUIDS status() entries. -- 2.11.0