r5792 - in /packages/libemail-simple-creator-perl/branches/upstream/current: Changes META.yml lib/Email/Simple/Creator.pm t/create.t

gregoa-guest at users.alioth.debian.org gregoa-guest at users.alioth.debian.org
Sat Jul 14 21:26:00 UTC 2007


Author: gregoa-guest
Date: Sat Jul 14 21:26:00 2007
New Revision: 5792

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5792
Log:
[svn-upgrade] Integrating new upstream version, libemail-simple-creator-perl (1.422)

Modified:
    packages/libemail-simple-creator-perl/branches/upstream/current/Changes
    packages/libemail-simple-creator-perl/branches/upstream/current/META.yml
    packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm
    packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t

Modified: packages/libemail-simple-creator-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/Changes?rev=5792&op=diff
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/Changes (original)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/Changes Sat Jul 14 21:26:00 2007
@@ -1,27 +1,32 @@
-1.421   2007-03-22
-        packaging improvements
 
-1.420   2007-02-23
-        reduce use of unneeded variables during creation
-        fix bugs that skipped creating headers with false values
-        use standard crlf for creating mail
-          A changelog entry below indicates that this was not the goal, but
-          all the code seems as if it was meant to do this.  There was a bug
-          in the logic, and there were no tests.
+1.422     2007-07-13
+          fixed header: why was it creating LFCR?
+          normalize line endings to CRLF in body
+          improve reliability of existing line-ending code
+          improve tests
+          packaging improvements
 
-1.41    2006-07-03
-        don't use no_plan in test; it breaks under old Test::More
-        (applied by RJBS, thanks to LTHEGLER)
+1.420     2007-02-23
+          reduce use of unneeded variables during creation
+          fix bugs that skipped creating headers with false values
+          use standard crlf for creating mail
+            A changelog entry below indicates that this was not the goal, but
+            all the code seems as if it was meant to do this.  There was a bug
+            in the logic, and there were no tests.
 
-1.4     2004-07-25
-        use Email::Date
+1.41      2006-07-03
+          don't use no_plan in test; it breaks under old Test::More
+          (applied by RJBS, thanks to LTHEGLER)
 
-1.3     2004-07-05
-        Create a message using its local crlf (Casey West).
-        Include timezone info in the Date header (Steffen Goeldner).
+1.4       2004-07-25
+          use Email::Date
 
-1.2     2004-07-05
-        Handle undefined values in the header list properly.
+1.3       2004-07-05
+          Create a message using its local crlf (Casey West).
+          Include timezone info in the Date header (Steffen Goeldner).
 
-1.1     ????-??-??
-        Initial Version
+1.2       2004-07-05
+          Handle undefined values in the header list properly.
+
+1.1       ????-??-??
+          Initial Version

Modified: packages/libemail-simple-creator-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/META.yml?rev=5792&op=diff
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/META.yml (original)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/META.yml Sat Jul 14 21:26:00 2007
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Email-Simple-Creator
-version:             1.420
+version:             1.422
 abstract:            Email::Simple constructor for starting anew.
 license:             perl
 generated_by:        ExtUtils::MakeMaker version 6.32

Modified: packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm?rev=5792&op=diff
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm (original)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm Sat Jul 14 21:26:00 2007
@@ -2,10 +2,10 @@
 use strict;
 
 use vars qw[$VERSION $CRLF];
-$VERSION = '1.420';
+$VERSION = '1.422';
 
 sub _crlf {
-  "\x0a\x0d";
+  "\x0d\x0a";
 }
 
 sub _date_header {
@@ -33,7 +33,10 @@
 sub create {
   my ($class, %args) = @_;
 
-  my $headers = $args{header} || [];
+  # We default it in here as well as below because by having it here, then we
+  # know that if there are no other headers, we'll get the proper CRLF.
+  # Otherwise, we get a message with incorrect CRLF. -- rjbs, 2007-07-13
+  my $headers = $args{header} || [ Date => $CREATOR->_date_header ];
   my $body    = $args{body} || '';
 
   my $empty   = q{};
@@ -51,9 +54,9 @@
   $email->header_set(Date => $CREATOR->_date_header)
     unless defined $email->header('Date');
 
-  # No reason to add a trailing CRLF if we have one already.
-  my $crlf = $email->crlf;
-  $body .= $crlf unless $crlf eq (substr $body, - length $crlf);
+  $body = (join $CREATOR->_crlf, split /\x0d\x0a|\x0a\x0d|\x0a|\x0d/, $body)
+        . $CREATOR->_crlf;
+
   $email->body_set($body);
 
   return $email;
@@ -65,7 +68,7 @@
 
 =head1 NAME
 
-Email::Simple::Creator - Email::Simple constructor for starting anew
+Email::Simple::Creator - build an Email::Simple object from scratch
 
 =head1 SYNOPSIS
 
@@ -96,35 +99,33 @@
 
   my $email = Email::Simple->create(header => [ @headers ], body => '...');
 
-This method is a constructor that creates an C<Email::Simple> object
+This method is a constructor that creates an Email::Simple object
 from a set of named parameters. The C<header> parameter's value is a
 list reference containing a set of headers to be created. The C<body>
 parameter's value is a scalar value holding the contents of the message
-body.
+body.  Line endings in the body will normalized to CRLF.
 
-If no C<Date> header is specified, one will be provided for you based on
-the C<gmtime()> of the local machine. This is because the C<Date> field
-is a required header and is a pain in the neck to create manually for
-every message. The C<From> field is also a required header, but it is
-I<not> provided for you.
+If no C<Date> header is specified, one will be provided for you based on the
+C<gmtime> of the local machine. This is because the C<Date> field is a required
+header and is a pain in the neck to create manually for every message. The
+C<From> field is also a required header, but it is I<not> provided for you.
 
-The parameters passed are used to create an email message that is passed
-to C<< Email::Simple->new() >>. C<create()> returns the value returned
-by C<new()>. With skill, that's an C<Email::Simple> object.
+=head1 PERL EMAIL PROJECT
 
-=head1 SEE ALSO
+This module is maintained by the Perl Email Project
 
-L<Email::Simple>,
-L<perl>.
+L<http://emailproject.perl.org/wiki/Email::Simple::Creator>
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-Casey West, <F<casey at geeknest.com>>.
+Casey West originally wrote Email::Simple::Creator in 2004.  Ricardo SIGNES
+took over maintenance in 2006.
 
-=head1 COPYRIGHT
+=head1 COPYRIGHT AND LICENSE
 
-  Copyright (c) 2004 Casey West.  All rights reserved.
-  This module is free software; you can redistribute it and/or modify it
-  under the same terms as Perl itself.
+Copyright (c) 2004 Casey West.
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
 
 =cut

Modified: packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t?rev=5792&op=diff
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t (original)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t Sat Jul 14 21:26:00 2007
@@ -1,16 +1,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 12;
+use Test::More tests => 25;
 
 use_ok 'Email::Simple';
 use_ok 'Email::Simple::Creator';
 
 sub tested_email {
-  my (%args) = @_;
+  my ($name, %args) = @_;
 
   my $email = Email::Simple->create(%args);
-  isa_ok $email, 'Email::Simple';
+  isa_ok $email, 'Email::Simple', "$name message";
 
   my $string = $email->as_string;
 
@@ -21,15 +21,36 @@
   
   is(
     sprintf("%03u %03u", map { ord } @last_two),
-    '010 013',
-    'stringified message ends with std CRLF'
+    '013 010',
+    "$name: stringified message ends with std CRLF"
+  );
+
+  unlike(
+    $email->as_string,
+    qr/(?<!\x0d)\x0a/,
+    "$name: message has no LF that aren't preceded by CR",
   );
 
   return $email;
 }
 
+{
+  my $body = "This body uses\x0d"
+           . "LF only, and not\x0d"
+           . "CRLF like it might ought to do.";
+
+  tested_email(crlf =>
+    body   => $body,
+    header => [
+      Subject => 'all tests and no code make rjbs something something',
+      From    => 'jack',
+      To      => 'sissy',
+    ],
+  );
+}
+
 { # should get an automatic date header
-  my $email = tested_email(
+  my $email = tested_email(auto_date =>
     header => [
       To => 'you',
     ],
@@ -43,8 +64,27 @@
   );
 }
 
+{ # who needs args?  (why is this legal? who knows -- rjbs, 2007-07-13)
+  my $email = tested_email('argless');
+
+  like(
+    $email->header('date'),
+    qr/^[A-Z][a-z]{2},/, # lame -- rjbs, 2007-02-23
+    "we got an auto-generated date header starting with a DOW",
+  );
+}
+
+{ # no need to add CRLF if it's there
+  my $email = tested_email(has_crlf =>
+    header => [
+      To => 'you',
+    ],
+    body => "test test\x0d\x0a",
+  );
+}
+
 { # no date header, we provided one
-  my $email = tested_email(
+  my $email = tested_email(has_date =>
     header => [
       Date       => 'testing',
       'X-Header' => 'one',
@@ -66,7 +106,7 @@
 END_MESSAGE
 
   my $string = $email->as_string;
-  $string  =~ s/\x0a\x0d/\n/gsm;
+  $string  =~ s/\x0d\x0a/\n/gsm;
 
   is(
     $string,
@@ -76,7 +116,7 @@
 }
 
 { # a few headers with false values
-  my $email = tested_email(
+  my $email = tested_email(falsies =>
     header => [
       Date  => undef,
       Zero  => 0,
@@ -104,7 +144,7 @@
 END_MESSAGE
 
   my $string = $email->as_string;
-  $string  =~ s/\x0a\x0d/\n/gsm;
+  $string  =~ s/\x0d\x0a/\n/gsm;
 
   is(
     $string,




More information about the Pkg-perl-cvs-commits mailing list