summaryrefslogtreecommitdiff
path: root/src/Util.php
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-11-25 11:15:16 +0000
committeruckelman <uckelman@nomic.net>2010-11-25 11:15:16 +0000
commitfb4c36d7cb6042fbec466f9bfb1cf3d0caeb6854 (patch)
treeed038ba4066f381541d5d39995962f37e192883f /src/Util.php
parentf74323a49897c9e646d586b68ec80cc0f3773d02 (diff)
Added has_rfc822_specials and rfc822_quote for handling names in email addresses.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@7492 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src/Util.php')
-rw-r--r--src/Util.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Util.php b/src/Util.php
index 0f1499a..47a26a4 100644
--- a/src/Util.php
+++ b/src/Util.php
@@ -24,6 +24,17 @@ function throw_if_null($arg) {
if ($arg === null) throw new Exception('argument is null');
}
+function has_rfc822_specials($str) {
+ // check for RFC822 specials (see section 3.3)
+ return strpbrk($str, '()<>@,;:\".[]') !== false;
+}
+
+function rfc822_quote($str) {
+ // turn \ and " into quoted-pairs, then quote the whole string
+ return '"' . str_replace(array("\\", "\"",),
+ array("\\\\", "\\\""), $str) . '"';
+}
+
function is_ascii($str) {
return !preg_match('/[^[:ascii:]]/', $str);
}