Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

properly escape chars when quoting phrase #2

Closed
wants to merge 1 commit into from

2 participants

@ruz
ruz commented

Not only " should be escaped, but \ as well.

This is in conformance with RFC822 and newer versions.

@ruz ruz properly escape chars when quoting phrase
Not only " should be escaped, but \ as well.
d21f709
@rjbs
Owner

Agreed, merged.

@rjbs rjbs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2012
  1. @ruz

    properly escape chars when quoting phrase

    ruz authored
    Not only " should be escaped, but \ as well.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +1 −1  lib/Email/Address.pm
  2. +7 −1 t/quoting.t
View
2  lib/Email/Address.pm
@@ -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"};
}
View
8 t/quoting.t
@@ -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';
@@ -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>};
+}
Something went wrong with that request. Please try again.