function uc_store_rfc2822_display_name in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_store/uc_store.module \uc_store_rfc2822_display_name()
- 7.3 uc_store/uc_store.module \uc_store_rfc2822_display_name()
Turns a text string into a valid RFC 2822 quoted string.
Any text string not consisting of a limited set of valid characters (notable printable non-valid characters include ',' and '.') needs to be quoted in order to be used an an e-mail header such as the "From" address. Double quotes in the original string are escaped (and nothing else).
1 call to uc_store_rfc2822_display_name()
- uc_store_email_from in uc_store/
uc_store.module - Returns store name and e-mail address in an RFC 2822 compliant string for use as a "From" address when sending e-mail to customers. The return string will look something like: Store Name <store@example.com>
File
- uc_store/
uc_store.module, line 1777 - Contains global Ubercart functions and store administration functionality.
Code
function uc_store_rfc2822_display_name($name) {
// Base64 encode $name string if it contains non-ASCII characters
$name = mime_header_encode($name);
// From RFC2822, section 3.4.2, define valid characters for an atom
$valid_chars = "[a-zA-Z0-9\\!\\#\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
// Display name is composed of 0 or more atoms separated by white space
if (!preg_match("/^({$valid_chars}*[ \t]*)*\$/", $name)) {
return '"' . addcslashes($name, '"') . '"';
}
return $name;
}