Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions lib/Horde/Prefs/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ public function __construct($params = [])
$this->_prefs = $params['prefs'];
$this->_user = $params['user'];

if (!($this->_identities = @unserialize($this->_prefs->getValue($this->_prefnames['identities'])))) {
$this->_identities = $this->_prefs->getDefault($this->_prefnames['identities']);
$raw = $this->_prefs->getValue($this->_prefnames['identities']);
if (is_string($raw) && strlen($raw)) {
$result = @unserialize($raw);
$this->_identities = is_array($result) ? $result : [];
} else {
$this->_identities = [];
}

$this->setDefault($this->_prefs->getValue($this->_prefnames['default_identity']));
Expand Down Expand Up @@ -343,7 +347,19 @@ public function verify($identity = null)
}

// To verify e-mail, first parse input, than re-parse in verify mode.
$ob = new Horde_Mail_Rfc822_Address($this->getValue($this->_prefnames['from_addr'], $identity));
$fromAddr = $this->getValue($this->_prefnames['from_addr'], $identity);
if (is_array($fromAddr)) {
$flat = [];
array_walk_recursive($fromAddr, function ($item) use (&$flat) {
if (is_string($item) && strlen($item)) {
$flat[] = $item;
}
});
$fromAddr = $flat[0] ?? '';
}
$fromAddr = is_string($fromAddr) ? $fromAddr : '';

$ob = new Horde_Mail_Rfc822_Address($fromAddr);
try {
$rfc822 = new Horde_Mail_Rfc822();
$rfc822->parseAddressList($ob, [
Expand Down Expand Up @@ -392,6 +408,16 @@ public function getName($ident = null)
public function getFromAddress($ident = null)
{
$val = $this->getValue($this->_prefnames['from_addr'], $ident);
if (is_array($val)) {
$flat = [];
array_walk_recursive($val, function ($item) use (&$flat) {
if (is_string($item) && strlen($item)) {
$flat[] = $item;
}
});
$val = $flat[0] ?? '';
}
$val = is_string($val) ? $val : '';
if (!strlen($val)) {
$val = $this->_user;
}
Expand All @@ -408,7 +434,7 @@ public function getFromAddress($ident = null)
*/
public function getDefaultFromAddress($fullname = false)
{
// We used to clone a fresh object but now we pass the original object - mutating it may have side effects.
// We used to clone a fresh object but now we pass the original object - mutating it may have side effects.
$ob = $this->getFromAddress();
$ob->personal = $fullname
? $this->getValue($this->_prefnames['fullname'])
Expand Down
Loading