]> git.proxmox.com Git - pmg-api.git/commitdiff
ldap cache: restructure from add-if-valid to skip-if-invalid
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Apr 2022 08:11:11 +0000 (10:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Apr 2022 08:12:08 +0000 (10:12 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/LDAPCache.pm

index 7aaf8fc1d6d0321a56c39312d629dd144238165a..f0698da26e27e61109296f8f3a7ea7166d2bc53e 100755 (executable)
@@ -161,18 +161,14 @@ sub queryusers {
                $mail = lc($mail);
                # Test if the Line starts with `proxyAddresses: [smtp]:`, discard this starting
                # string, so that $mail is only the plain address without any extra characters
-
                $mail =~ s/^smtp[\:\$]//gs;
 
+               next if $mail =~ m/[\{\}\\\/]/ || $mail !~ m/^\S+\@\S+$/;
                # exclude sip and x500 addresses in proxyAddresses http://archive.today/XIerB
-               if (
-                   $mail !~ m/[\{\}\\\/]/ &&
-                   $mail =~ m/^\S+\@\S+$/ &&
-                   $mail !~  m/^(sip|x500)[\:\$]/
-               ) {
-                   $umails->{$mail} = 1;
-                   $pmail = $mail if !$pmail;
-               }
+               next if $mail =~ m/^(sip|x500)[\:\$]/;
+
+               $umails->{$mail} = 1;
+               $pmail = $mail if !$pmail; # use first one as primary mail
            }
        }
        my $addresses = [ keys %$umails ];