Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly escape chars when quoting phrase #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Email/Address.pm
Expand Up @@ -441,7 +441,7 @@ sub _enquoted_phrase {
return $phrase if $phrase =~ /\A=\?.+\?=\z/;

$phrase =~ s/\A"(.+)"\z/$1/;
$phrase =~ s/\"/\\"/g;
$phrase =~ s/([\\"])/\\$1/g;

return qq{"$phrase"};
}
Expand Down
8 changes: 7 additions & 1 deletion t/quoting.t
Expand Up @@ -2,7 +2,7 @@
use strict;

use Email::Address;
use Test::More tests => 6;
use Test::More tests => 8;

my $phrase = q{jack!work};
my $email = 'jack@work.com';
Expand Down Expand Up @@ -36,3 +36,9 @@ is(
);

is($ea3->phrase, $phrase, "the phrase method returns the right thing");

{
my $ea = Email::Address->new(q{jack "\\" robinson}, 'jack@work.com');
is $ea->phrase, q{jack "\\" robinson};
is $ea->format, q{"jack \\"\\\\\\" robinson" <jack@work.com>};
}