diff --git a/dovecot/edit_mail.cgi b/dovecot/edit_mail.cgi index 98df1adcf..610416aa0 100755 --- a/dovecot/edit_mail.cgi +++ b/dovecot/edit_mail.cgi @@ -22,9 +22,15 @@ else { if ($env =~ s/:INDEX=([^:]+)//) { $index = $1; } +elsif (&find("mail_index_path", $conf, 2)) { + $index = &find_value("mail_index_path", $conf); + } if ($env =~ s/:CONTROL=([^:]+)//) { $control = $1; } +elsif (&find("mail_cache_path", $conf, 2)) { + $control = &find_value("mail_cache_path", $conf); + } for($i=0; $i<@mail_envs; $i++) { $envmode = $i if ($mail_envs[$i] eq $env); } diff --git a/dovecot/save_mail.cgi b/dovecot/save_mail.cgi index bd03b4ecf..56f2cb0ed 100755 --- a/dovecot/save_mail.cgi +++ b/dovecot/save_mail.cgi @@ -17,18 +17,41 @@ else { } # Add index file location -$env || !$in{'indexmode'} || &error($text{'mail_eindexmode'}); -$env || !$in{'controlmode'} || &error($text{'mail_econtrolmode'}); -if ($in{'indexmode'} == 1) { - $env .= ":INDEX=MEMORY"; +if (&version_below("2.4")) { + $env || !$in{'indexmode'} || &error($text{'mail_eindexmode'}); + $env || !$in{'controlmode'} || &error($text{'mail_econtrolmode'}); + if ($in{'indexmode'} == 1) { + $env .= ":INDEX=MEMORY"; + } + elsif ($in{'indexmode'} == 2) { + $in{'index'} =~ /^\/\S+$/ || &error($text{'mail_eindex'}); + $env .= ":INDEX=".$in{'index'}; + } + if ($in{'controlmode'}) { + $in{'control'} =~ /^\/\S+$/ || &error($text{'mail_econtrol'}); + $env .= ":CONTROL=".$in{'control'}; + } } -elsif ($in{'indexmode'} == 2) { - $in{'index'} =~ /^\/\S+$/ || &error($text{'mail_eindex'}); - $env .= ":INDEX=".$in{'index'}; - } -if ($in{'controlmode'}) { - $in{'control'} =~ /^\/\S+$/ || &error($text{'mail_econtrol'}); - $env .= ":CONTROL=".$in{'control'}; +else { + # Parse index and control first + if ($in{'indexmode'} == 1) { + $index = "MEMORY"; + } + elsif ($in{'indexmode'} == 2) { + $in{'index'} =~ /^\/\S+$/ || $in{'index'} =~ /^~\S+$/ || + &error($text{'mail_eindex'}); + $index = $in{'index'}; + } + if ($in{'controlmode'}) { + $in{'control'} =~ /^\/\S+$/ || $in{'control'} =~ /^~\S+$/ || + &error($text{'mail_econtrol'}); + $control = $in{'control'}; + } + # Directly save dedicated mail_cache_path and mail_index_path + &save_directive($conf, "mail_index_path", + $index eq "" ? undef : $index); + &save_directive($conf, "mail_cache_path", + $control eq "" ? undef : $control); } if (&find("default_mail_env", $conf, 2)) {