}
sub xs_pairs { # for JMAP, RFC 8621 section 4.1.2.3
- [ map { # LHS (name) may be undef
- [ $_->phrase // $_->comment, $_->address ]
+ [ map { # LHS (name) may be undef if there's an address
+ my @p = ($_->phrase // $_->comment, $_->address);
+ # show original if totally bogus:
+ $p[0] = $_->original unless defined $p[1];
+ \@p;
} parse_email_addresses($_[0]) ];
}
}
}
$line_len += length($n);
- $url = $addr2url->{lc $pair->[1]};
+ $url = $addr2url->{lc($pair->[1] // '')};
$html .= $url ? qq(<a\nhref="$url$t">$n</a>) : $n;
}
($html, $len + $line_len);
is_deeply([], \@emails , 'no address for local address');
@names = $emails->('Local User <user>');
is_deeply([], \@names, 'no address, no name');
+
+ my $p = $pairs->('NAME, a@example, wtf@');
+ is scalar(grep { defined($_->[0] // $_->[1]) } @$p),
+ scalar(@$p), 'something is always defined in bogus pairs';
}
test_pkg('PublicInbox::Address');