From: Dobrica Pavlinusic Date: Tue, 4 Oct 2016 12:01:54 +0000 (+0200) Subject: unroll multiple e-mail addresses into mail, mail_1, mail_2 ... X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=commitdiff_plain;h=72a182f851703954afd534a9e4623103b8efdab2;ds=inline unroll multiple e-mail addresses into mail, mail_1, mail_2 ... --- diff --git a/bin/ldap-rewrite.pl b/bin/ldap-rewrite.pl index 0a3acfa..e9be738 100755 --- a/bin/ldap-rewrite.pl +++ b/bin/ldap-rewrite.pl @@ -157,6 +157,20 @@ sub log_response { foreach my $i ( 0 .. $#{ $attr->{vals} } ) { $attr->{vals}->[$i] =~ s/^u2010/p2010/gs && warn "FIXME group"; } + } elsif ( $attr->{type} eq 'mail' ) { + my @emails; + foreach my $i ( 0 .. $#{ $attr->{vals} } ) { + my $e = $attr->{vals}->[$i]; + if ( $e =~ m/\s+/ ) { + push @emails, split(/\s+/, $e); + } else { + push @emails, $e; + } + } + $attr->{vals} = [ shift @emails ]; + foreach my $i ( 0 .. $#emails ) { + push @attrs, { type => $attr->{type} . '_' . ( $i + 1 ) , vals => [ $emails[$i] ] }; + } } }