diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Util.php | 11 |
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); } |