Skip to content

Commit

Permalink
Ignore invalid user preferences. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3c authored Sep 26, 2024
1 parent 5a84150 commit aa34d5f
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions custom_from.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private static function get_configuration(rcmail $rcmail)
return array();
}

// Initialize rules with global settings
$rules_config = $rcmail->config->get('custom_from_header_rules');
$rules = array();

Expand All @@ -321,38 +322,19 @@ private static function get_configuration(rcmail $rcmail)
}
}

switch (self::get_preference($rcmail, self::PREFERENCE_COMPOSE_SUBJECT, '')) {
case 'always':
$subject = 'deo';
// Overwrite rules with user preference if valid
$subject = self::get_preference($rcmail, self::PREFERENCE_COMPOSE_SUBJECT, '');
$subject_rules = array('always' => 'deo', 'domain' => 'de', 'exact' => 'e', 'never' => '');

break;

case 'domain':
$subject = 'de';

break;

case 'exact':
$subject = 'e';

break;

case 'never':
$subject = '';
if (isset($subject_rules[$subject])) {
$rule = $subject_rules[$subject];

break;

default:
$subject = null;

break;
}

if ($subject !== null) {
$rules['bcc'] = $subject;
$rules['cc'] = $subject;
$rules['to'] = $subject;
$rules['x-original-to'] = $subject;
foreach (array('bcc', 'cc', 'to', 'x-original-to') as $header) {
if ($rule !== '')
$rules[$header] = $rule;
else
unset($rules[$header]);
}
}

return $rules;
Expand Down

0 comments on commit aa34d5f

Please sign in to comment.