[Jifty-commit] jifty branch, master, updated. 28da6bb998865f7a7978bed13f6c12a6bc5027f6
Jifty commits
jifty-commit at lists.jifty.org
Wed Dec 30 12:33:51 EST 2009
The branch, master has been updated
via 28da6bb998865f7a7978bed13f6c12a6bc5027f6 (commit)
via 928ce583385d8ad6cc935fea053a6e2d9a9cdcd7 (commit)
via c5d34b44ef62f165c2db33ce0fcf3818ba8fce1c (commit)
via 616b795d6bddc834e694f6205be80845363c771a (commit)
via 69182f1e37ca5daac1ff46f5660ee277055f93c3 (commit)
via 4a50b4ab658a123ce7e32dc57cb40d277c554d8f (commit)
via 22b882750bff52b4b6f4fb3b409ac63b3ae50f4f (commit)
via 6a86063b465cba760c745e409da3a56454e17445 (commit)
via 0d39ba54eaf75ccd663eda8dd4ac89b4b9b0d15c (commit)
from c2cad37e19dd3d53cbf4c18eefa0a199cbfe0192 (commit)
Summary of changes:
Makefile.PL | 4 +---
lib/Jifty/Notification.pm | 17 +++++++++--------
t/TestApp-Notifications/t/encoding-2.t | 20 --------------------
t/TestApp-Notifications/t/encoding.t | 31 ++++++++++++++++++++++---------
4 files changed, 32 insertions(+), 40 deletions(-)
delete mode 100644 t/TestApp-Notifications/t/encoding-2.t
- Log -----------------------------------------------------------------
commit 0d39ba54eaf75ccd663eda8dd4ac89b4b9b0d15c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:12:56 2009 -0500
Revert 4db2709; Email::MIME takes bytes, and full_body is characters
Email::MIME takes _bytes_, not characters, for the "body" argument, so
we need to encode the full_body (which has characters) into UTF8.
Modern Email::MIME->create takes a "body_str" argument which does the
encoding for us, but Email::MIME::CreateHTML doesn't grok it (yet).
diff --git a/lib/Jifty/Notification.pm b/lib/Jifty/Notification.pm
index f597dc6..af4e1e1 100644
--- a/lib/Jifty/Notification.pm
+++ b/lib/Jifty/Notification.pm
@@ -113,9 +113,12 @@ sub send_one_message {
if ( defined $self->html_body ) {
- # NOTICE: we should keep string in perl string (with utf8
- # flag) rather then encode it into octets. Email::MIME would
- # call Encode::encode in its create function.
+ # Email::MIME takes _bytes_, not characters, for the "body"
+ # argument, so we need to encode the full_body into UTF8.
+ # Modern Email::MIME->create takes a "body_str" argument which
+ # does the encoding for us, but Email::MIME::CreateHTML
+ # doesn't grok it. See also L</parts> for the other location
+ # which does the encode.
$message = Email::MIME->create_html(
header => [
From => $from,
@@ -125,8 +128,8 @@ sub send_one_message {
attributes => \%attrs,
text_body_attributes => \%attrs,
body_attributes => \%attrs,
- text_body => $self->full_body,
- body => $self->full_html,
+ text_body => Encode::encode_utf8( $self->full_body ),
+ body => Encode::encode_utf8( $self->full_html ),
embed => 0,
inline_css => 0,
);
@@ -333,7 +336,7 @@ sub parts {
# its create function.
return [ Email::MIME->create(
attributes => { charset => 'UTF-8' },
- body => $self->full_body,
+ body => Encode::encode_utf8( $self->full_body ),
) ];
}
commit 6a86063b465cba760c745e409da3a56454e17445
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:23:36 2009 -0500
Use Email::MIME's ->body_str method, which does charset decoding
This also causes "use encoding" to be no longer necessary. The "use
encoding" line papered over the fact that emails loaded from the file
weren't being decoded -- "use encoding" happened to be silently
decoding them as UTF8, however.
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index 66f3c56..7ad4b6a 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -4,7 +4,6 @@ use strict;
use Jifty::Test::Dist tests => 4;
use TestApp::Notifications::Notification;
-use encoding 'utf8';
sub send_and_receive {
local $Test::Builder::Level = $Test::Builder::Level + 1;
@@ -21,7 +20,7 @@ sub send_and_receive {
Jifty::Test->teardown_mailbox;
is(scalar @emails, 1, "Sent one notification email");
- return $emails[0]->body;
+ return Email::MIME->new($emails[0]->as_string)->body_str;
}
{
commit 22b882750bff52b4b6f4fb3b409ac63b3ae50f4f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:24:47 2009 -0500
Bodies should be characters, not bytes
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index 7ad4b6a..c7f5aea 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -25,7 +25,6 @@ sub send_and_receive {
{
my $str = "Simple Latin-1\n\n"; # latin bytes string
- utf8::encode( $str ); # upgrade $str to utf8 bytes string
my $body = send_and_receive( $str );
is($body, $str );
}
@@ -33,7 +32,6 @@ sub send_and_receive {
# XXX: should this be "All L\N{LATIN SMALL LETTER E WITH ACUTE}on's fault"
{
my $str = "All L\x{c3}\x{a9}on's fault\n\n"; # latin1 bytes string
- utf8::encode( $str ); # upgrade to utf8 bytes string
my $body = send_and_receive( $str );
is($body, $str );
}
commit 4a50b4ab658a123ce7e32dc57cb40d277c554d8f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:27:27 2009 -0500
Use the explicit character name from "use charnames"
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index c7f5aea..0abe273 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -4,6 +4,7 @@ use strict;
use Jifty::Test::Dist tests => 4;
use TestApp::Notifications::Notification;
+use charnames ':full';
sub send_and_receive {
local $Test::Builder::Level = $Test::Builder::Level + 1;
@@ -29,9 +30,8 @@ sub send_and_receive {
is($body, $str );
}
-# XXX: should this be "All L\N{LATIN SMALL LETTER E WITH ACUTE}on's fault"
{
- my $str = "All L\x{c3}\x{a9}on's fault\n\n"; # latin1 bytes string
+ my $str = "All L\N{LATIN SMALL LETTER E WITH ACUTE}on's fault\n\n";
my $body = send_and_receive( $str );
is($body, $str );
}
commit 69182f1e37ca5daac1ff46f5660ee277055f93c3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:31:06 2009 -0500
Fold t/encoding-2.t into t/encoding.t
The t/encoding-2.t test was only failing because Jifty::Test::Email is
based on Test::Email, which is based on MIME::Entity -- which makes no
attempt to parse or understand character sets. Thus, the message
failed to match the regular expression, which was in characters.
Using the same infrastructure as t/encoding.t causes the test to
succeed.
diff --git a/t/TestApp-Notifications/t/encoding-2.t b/t/TestApp-Notifications/t/encoding-2.t
deleted file mode 100644
index 903dfe2..0000000
--- a/t/TestApp-Notifications/t/encoding-2.t
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env perl
-use warnings;
-use strict;
-use Jifty::Test::Dist tests => 4;
-use Jifty::Test::Email;
-use Test::Exception;
-
-mail_ok {
- my $n = Jifty->app_class( 'Notification' => 'Foo' )->new;
- $n->body( "Simple Latin-1\n\n" );
- $n->send_one_message;
- } { body => qr'Simple Latin-1's };
-
-mail_ok {
- my $n = Jifty->app_class( 'Notification' => 'Foo' )->new;
- $n->body( "䏿\n\n\n" );
- $n->send_one_message;
- } { body => qr'䏿's };
-
-1;
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index 0abe273..3e40e50 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -2,9 +2,10 @@
use warnings;
use strict;
-use Jifty::Test::Dist tests => 4;
+use Jifty::Test::Dist tests => 6;
use TestApp::Notifications::Notification;
use charnames ':full';
+use utf8;
sub send_and_receive {
local $Test::Builder::Level = $Test::Builder::Level + 1;
@@ -27,11 +28,17 @@ sub send_and_receive {
{
my $str = "Simple Latin-1\n\n"; # latin bytes string
my $body = send_and_receive( $str );
- is($body, $str );
+ is($body, $str, "Latin looks fine" );
}
{
my $str = "All L\N{LATIN SMALL LETTER E WITH ACUTE}on's fault\n\n";
my $body = send_and_receive( $str );
- is($body, $str );
+ is($body, $str, "Implicit UTF8 char" );
+}
+
+{
+ my $str = "䏿\n\n\n";
+ my $body = send_and_receive( $str );
+ is($body, $str, "Explicit UTF8 char" );
}
commit 616b795d6bddc834e694f6205be80845363c771a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:47:07 2009 -0500
Messages seem to loose a newline somewhere between sending and loading
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index 3e40e50..c1398db 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -22,7 +22,7 @@ sub send_and_receive {
Jifty::Test->teardown_mailbox;
is(scalar @emails, 1, "Sent one notification email");
- return Email::MIME->new($emails[0]->as_string)->body_str;
+ return Email::MIME->new($emails[0]->as_string)->body_str . "\n";
}
{
commit c5d34b44ef62f165c2db33ce0fcf3818ba8fce1c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 02:34:15 2009 -0500
Test L10N round-trips through notifications, using _
diff --git a/t/TestApp-Notifications/t/encoding.t b/t/TestApp-Notifications/t/encoding.t
index c1398db..39f60fe 100644
--- a/t/TestApp-Notifications/t/encoding.t
+++ b/t/TestApp-Notifications/t/encoding.t
@@ -2,7 +2,7 @@
use warnings;
use strict;
-use Jifty::Test::Dist tests => 6;
+use Jifty::Test::Dist tests => 8;
use TestApp::Notifications::Notification;
use charnames ':full';
use utf8;
@@ -42,3 +42,12 @@ sub send_and_receive {
my $body = send_and_receive( $str );
is($body, $str, "Explicit UTF8 char" );
}
+
+{
+ my $lh = Jifty::I18N->get_handle("ja");
+ Jifty::I18N->install_global_loc(\$lh);
+
+ my $str = _("Alert") . "\n\n";
+ my $body = send_and_receive( $str );
+ is($body, $str, "L10N UTF8 char" );
+}
commit 928ce583385d8ad6cc935fea053a6e2d9a9cdcd7
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 12:26:27 2009 -0500
Bump Email::MIME dep to something that provides ->body_str
It also merges in Email::MIME::Creator and Email::MIME::Modifier, so
we can drop those dependencies entirely.
diff --git a/Makefile.PL b/Makefile.PL
index 3638972..9d49555 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -27,11 +27,9 @@ requires('DateTime::Locale');
requires('Date::Manip');
requires('Email::Folder');
requires('Email::LocalDelivery' => 0.217 );
-requires('Email::MIME' => 1.861);
-requires('Email::MIME::Creator' => 1.450 );
+requires('Email::MIME' => 1.900 );
requires('Email::MIME::ContentType' => 1.012 );
requires('Email::MIME::CreateHTML');
-requires('Email::MIME::Modifier' => 1.442 );
requires('Email::Send' => '2.10');
requires('Email::Simple' => 2.003);
requires('Email::Simple::Creator' => 1.400 );
commit 28da6bb998865f7a7978bed13f6c12a6bc5027f6
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 30 12:28:15 2009 -0500
Remove unnecessary "use" lines
Now that Email::MIME::Modifier and ::Creator are in Email::MIME, drop
the explicit "use"
diff --git a/lib/Jifty/Notification.pm b/lib/Jifty/Notification.pm
index af4e1e1..249a691 100644
--- a/lib/Jifty/Notification.pm
+++ b/lib/Jifty/Notification.pm
@@ -5,9 +5,7 @@ package Jifty::Notification;
use base qw/Jifty::Object Class::Accessor::Fast/;
use Email::Send ();
-use Email::MIME::Creator;
use Email::MIME::CreateHTML;
-use Email::MIME::Modifier;
__PACKAGE__->mk_accessors(
qw/body html_body preface footer subject from _recipients _to_list to/);
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list