-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
indexer: in one place, use proper email header formatting
This is a test run for things to come. In most places, we only use the user email address, not their name. But in some places, most especially in paused, we use their name. There were two problems there: 1. we were using the ASCII name, which we really don't need to do 2. we were not escaping any quotes (or anything else) in the name field, which could cause problems if someone puts a double quote in their fullname It wasn't trivial to test and fix those locations because we don't (yet!) have any tests for paused. This introduces the use of fullname to mldistwatch, using the new form: get the PAUSE::MailAddress for the user, then use its ->email_object method to create a Email::MIME::Header::AddressList. We'll switch all the mailing to use this, soon.
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use utf8; | ||
|
||
use 5.10.1; | ||
use lib 't/lib'; | ||
use lib 't/privatelib'; # Stub PrivatePAUSE | ||
|
@@ -581,6 +583,36 @@ subtest "do not index dists without META file" => sub { | |
); | ||
}; | ||
|
||
subtest "quotes in username" => sub { | ||
my $pause = PAUSE::TestPAUSE->init_new; | ||
|
||
my $initial_result = $pause->test_reindex; | ||
|
||
my $dbh = $initial_result->connect_mod_db; | ||
|
||
$dbh->do( | ||
"INSERT INTO users (userid, email, fullname, asciiname) | ||
VALUES (?, ?, ?, ?)", | ||
undef, | ||
'PERSON', '[email protected]', q{R★S"'<xmp>}, q{R*S"'<xmp>}, | ||
); | ||
|
||
$pause->upload_author_fake(PERSON => 'Not-Very-Meta-1.234.tar.gz', { | ||
omitted_files => [ qw( META.yml META.json ) ], | ||
}); | ||
|
||
my $result = $pause->test_reindex; | ||
|
||
my ($to) = ($result->deliveries)[0]->{email}->object->header_as_obj('To'); | ||
my @addresses = $to->addresses; | ||
|
||
is($addresses[0]->address, q{[email protected]}, "first address is right"); | ||
is($addresses[0]->phrase, q{R★S"'<xmp>}, "first name is right"); | ||
|
||
is($addresses[1]->address, q{[email protected]}, "second address is right"); | ||
is($addresses[1]->phrase, q{PAUSE Admin}, "second name is right"); | ||
}; | ||
|
||
done_testing; | ||
|
||
# Local Variables: | ||
|