Add Horde_Imap_Client_Utils::stripNonAtomChars()
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Apr 2010 21:03:47 +0000 (15:03 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Apr 2010 21:15:04 +0000 (15:15 -0600)
framework/Imap_Client/lib/Horde/Imap/Client/Utils.php
framework/Imap_Client/package.xml

index a11588d..7d8dff5 100644 (file)
@@ -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.
index 7dcb470..b23816c 100644 (file)
@@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>alpha</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Add sequence sort (numeric sort by UID/sequence number).
+ <notes>* 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.