The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Changes 230
Encode.pm 22
Encode.xs 44
MANIFEST 12
META.json 22
META.yml 33
Makefile.PL 11
Unicode/Unicode.pm 24
Unicode/Unicode.xs 22
lib/Encode/Alias.pm 22
lib/Encode/MIME/Header.pm 1312
t/encoding-locale.t 025
t/mime-header.t 2021
13 files changed (This is a version diff) 54110
@@ -1,8 +1,36 @@
 # Revision history for Perl extension Encode.
 #
-# $Id: Changes,v 2.78 2015/09/24 02:19:21 dankogai Exp dankogai $
+# $Id: Changes,v 2.80 2016/01/25 14:54:13 dankogai Exp dankogai $
 #
-$Revision: 2.78 $ $Date: 2015/09/24 02:19:21 $
+$Revision: 2.80 $ $Date: 2016/01/25 14:54:13 $
+! lib/Encode/MIME/Header.pm t/mime-header.t
+  Address #111417: 2.79 breaks Email-MIME-1.936 tests
+  https://rt.cpan.org/Ticket/Display.html?id=111417
+
+2.79 2016/01/22 06:44:53
+! lib/Encode/MIME/Header.pm t/mime-header.t
+  Address: #88717:
+    encode('MIME-Header') does not find word boundaries correctly
+  By addressing this age-old bug, many other open RTs will be closed.
+  https://rt.cpan.org/Ticket/Display.html?id=88717
+! lib/Encode/MIME/Header.pm
+  Address RT#107775: Inserts an empty line in an encoded header field
+  https://rt.cpan.org/Ticket/Display.html?id=107775
+! lib/Encode/Alias.pm
+  Pulled: Update Alias.pm
+  https://github.com/dankogai/p5-encode/pull/47
+! Encode.xs Unicode/Unicode.xs
+  Pulled: static funcs in Encode.xs and Unicode.xs
+  https://github.com/dankogai/p5-encode/pull/46
+! Unicode/Unicode.pm
+  Pulled: Unicode.pm: Fix POD error
+  https://github.com/dankogai/p5-encode/pull/45
+- META.yml
+! MANIFEST
+  META.yml should not be included in the dist file.
+  It is also obsolete.
+
+2.78 2015/09/24 02:19:21
 ! Makefile.PL
   Mend pull/42 again.  This time correctly.
 ! lib/Encode/Supported.pod
@@ -1,10 +1,10 @@
 #
-# $Id: Encode.pm,v 2.78 2015/09/24 02:18:32 dankogai Exp $
+# $Id: Encode.pm,v 2.80 2016/01/25 14:54:01 dankogai Exp $
 #
 package Encode;
 use strict;
 use warnings;
-our $VERSION = sprintf "%d.%02d", q$Revision: 2.78 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 2.80 $ =~ /(\d+)/g;
 use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
 use XSLoader ();
 XSLoader::load( __PACKAGE__, $VERSION );
@@ -1,5 +1,5 @@
 /*
- $Id: Encode.xs,v 2.34 2015/09/15 13:53:27 dankogai Exp $
+ $Id: Encode.xs,v 2.35 2016/01/22 06:33:07 dankogai Exp $
  */
 
 #define PERL_NO_GET_CONTEXT
@@ -20,7 +20,7 @@
    encode_method().  1 is recommended. 2 restores NI-S original */
 #define ENCODE_XS_USEFP   1
 
-#define UNIMPLEMENTED(x,y) y x (SV *sv, char *encoding) {		\
+#define UNIMPLEMENTED(x,y) static y x (SV *sv, char *encoding) {	\
 			Perl_croak_nocontext("panic_unimplemented");	\
                         PERL_UNUSED_VAR(sv); \
                         PERL_UNUSED_VAR(encoding); \
@@ -42,7 +42,7 @@ UNIMPLEMENTED(_encoded_bytes_to_utf8, I32)
                                 UTF8_ALLOW_NON_CONTINUATION |     \
                                 UTF8_ALLOW_LONG))
 
-void
+static void
 Encode_XSEncoding(pTHX_ encode_t * enc)
 {
     dSP;
@@ -66,7 +66,7 @@ Encode_XSEncoding(pTHX_ encode_t * enc)
     SvREFCNT_dec(sv);
 }
 
-void
+static void
 call_failure(SV * routine, U8 * done, U8 * dest, U8 * orig)
 {
     /* Exists for breakpointing */
@@ -20,7 +20,6 @@ JP/Makefile.PL	Encode extension
 KR/KR.pm		Encode extension
 KR/Makefile.PL		Encode extension
 MANIFEST		Encode extension
-META.yml                                Module meta-data in YAML
 Makefile.PL		Encode extension makefile writer
 README		Encode extension
 Symbol/Makefile.PL     Encode extension
@@ -76,6 +75,7 @@ t/enc_module.enc test data for t/enc_module.t
 t/enc_module.t	test script
 t/enc_utf8.t	test script
 t/encoding.t	test script
+t/encoding-locale.t  test script
 t/fallback.t	test script
 t/from_to.t	test script
 t/gb2312.enc	test data
@@ -208,4 +208,5 @@ ucm/posix-bc.ucm	Unicode Character Map
 ucm/shiftjis.ucm	Unicode Character Map
 ucm/symbol.ucm	Unicode Character Map
 ucm/viscii.ucm	Unicode Character Map
+META.yml                                 Module YAML meta-data (added by MakeMaker)
 META.json                                Module JSON meta-data (added by MakeMaker)
@@ -4,7 +4,7 @@
       "unknown"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005",
+   "generated_by" : "ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150005",
    "license" : [
       "perl_5"
    ],
@@ -43,6 +43,6 @@
          "url" : "https://github.com/dankogai/p5-encode"
       }
    },
-   "version" : "2.78",
+   "version" : "2.80",
    "x_serialization_backend" : "JSON::PP version 2.27300"
 }
@@ -7,7 +7,7 @@ build_requires:
 configure_requires:
   ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150005'
+generated_by: 'ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150005'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -22,5 +22,5 @@ requires:
   parent: '0.221'
 resources:
   repository: https://github.com/dankogai/p5-encode
-version: '2.78'
-x_serialization_backend: 'CPAN::Meta::YAML version 0.016'
+version: '2.80'
+x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile.PL,v 2.16 2015/09/24 02:19:21 dankogai Exp dankogai $
+# $Id: Makefile.PL,v 2.16 2015/09/24 02:19:21 dankogai Exp $
 #
 use 5.007003;
 use strict;
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 no warnings 'redefine';
 
-our $VERSION = do { my @r = ( q$Revision: 2.14 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
+our $VERSION = do { my @r = ( q$Revision: 2.15 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
 
 use XSLoader;
 XSLoader::load( __PACKAGE__, $VERSION );
@@ -178,7 +178,9 @@ When BE or LE is omitted during decode(), it checks if BOM is at the
 beginning of the string; if one is found, the endianness is set to
 what the BOM says.  
 
-=item Default Byte Order
+=item *
+
+Default Byte Order
 
 When no BOM is found, Encode 2.76 and blow croaked.  Since Encode
 2.77, it falls back to BE accordingly to RFC2781 and the Unicode
@@ -1,5 +1,5 @@
 /*
- $Id: Unicode.xs,v 2.13 2015/09/15 13:53:27 dankogai Exp $
+ $Id: Unicode.xs,v 2.14 2016/01/22 06:33:07 dankogai Exp $
  */
 
 #define PERL_NO_GET_CONTEXT
@@ -89,7 +89,7 @@ enc_unpack(pTHX_ U8 **sp, U8 *e, STRLEN size, U8 endian)
     return v;
 }
 
-void
+static void
 enc_pack(pTHX_ SV *result, STRLEN size, U8 endian, UV value)
 {
     U8 *d = (U8 *) SvPV_nolen(result);
@@ -2,7 +2,7 @@ package Encode::Alias;
 use strict;
 use warnings;
 no warnings 'redefine';
-our $VERSION = do { my @r = ( q$Revision: 2.19 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
+our $VERSION = do { my @r = ( q$Revision: 2.20 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
 use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
 
 use Exporter 'import';
@@ -139,7 +139,7 @@ sub init_aliases {
     define_alias( qr/^UCS-?2-?LE$/i => '"UCS-2LE"' );
     define_alias(
         qr/^UCS-?2-?(BE)?$/i    => '"UCS-2BE"',
-        qr/^UCS-?4-?(BE|LE)?$/i => 'uc("UTF-32$1")',
+        qr/^UCS-?4-?(BE|LE|)?$/i => 'uc("UTF-32$1")',
         qr/^iso-10646-1$/i      => '"UCS-2BE"'
     );
     define_alias(
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 no warnings 'redefine';
 
-our $VERSION = do { my @r = ( q$Revision: 2.17 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
+our $VERSION = do { my @r = ( q$Revision: 2.19 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
 use Encode qw(find_encoding encode_utf8 decode_utf8);
 use MIME::Base64;
 use Carp;
@@ -39,10 +39,9 @@ sub perlio_ok   { 0 }
 sub decode($$;$) {
     use utf8;
     my ( $obj, $str, $chk ) = @_;
-
     # zap spaces between encoded words
     $str =~ s/\?=\s+=\?/\?==\?/gos;
-
+    
     # multi-line header to single line
     $str =~ s/(?:\r\n|[\r\n])[ \t]//gos;
 
@@ -108,20 +107,20 @@ my $re_encoded_word = qr{
 
 my $re_especials = qr{$re_encoded_word|$especials}xo;
 
+# cf:
+#    https://rt.cpan.org/Ticket/Display.html?id=88717
+#    https://www.ietf.org/rfc/rfc0822.txt
+my $re_linear_white_space = qr{(?:[ \t]|\r\n?)};
+
 sub encode($$;$) {
     my ( $obj, $str, $chk ) = @_;
     my @line = ();
     for my $line ( split /\r\n|[\r\n]/o, $str ) {
         my ( @word, @subline );
-        for my $word ( split /($re_especials)/o, $line ) {
-            if (   $word =~ /[^\x00-\x7f]/o
-                or $word =~ /^$re_encoded_word$/o )
-            {
-                push @word, $obj->_encode($word);
-            }
-            else {
-                push @word, $word;
-            }
+        if ($line =~ /\A([\w\-]+:\s+)(.*)\z/o) {
+            push @word, $1, $obj->_encode($2); # "X-Header-Name: ..."
+        } else {
+            push @word, $obj->_encode($line);  # anything else
         }
         my $subline = '';
         for my $word (@word) {
@@ -136,7 +135,7 @@ sub encode($$;$) {
             $subline .= $word;
         }
         length($subline) and push @subline, $subline;
-        push @line, join( "\n " => @subline );
+        push @line, join( "\n " => grep !/^$/, @subline );
     }
     $_[1] = '' if $chk;
     return (substr($str, 0, 0) . join( "\n", @line ));
@@ -0,0 +1,25 @@
+#
+# This test aims to detect (using CPAN Testers) platforms where the locale
+# encoding detection doesn't work.
+#
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use encoding ();
+use Encode qw<find_encoding>;
+
+my $locale_encoding = encoding::_get_locale_encoding;
+
+SKIP: {
+    is(ref $locale_encoding, '', '_get_locale_encoding returns a scalar value')
+	or skip 'no locale encoding found', 1;
+
+    my $enc = find_encoding($locale_encoding);
+    ok(defined $enc, 'encoding returned is supported')
+	or diag("Encoding: ", explain($locale_encoding));
+    isa_ok($enc, 'Encode::Encoding');
+    note($locale_encoding, ' => ', $enc->name);
+}
@@ -1,5 +1,5 @@
 #
-# $Id: mime-header.t,v 2.6 2013/08/14 02:29:54 dankogai Exp $
+# $Id: mime-header.t,v 2.8 2016/01/25 14:54:13 dankogai Exp dankogai $
 # This script is written in utf8
 #
 BEGIN {
@@ -73,28 +73,28 @@ Subject: 漢字、カタカナ、ひらがなを含む、非常に長いタイ
 EOS
 
 my $bheader =<<'EOS';
-From:=?UTF-8?B?IOWwj+mjvCDlvL4g?=<dankogai@dan.co.jp>
-To: dankogai@dan.co.jp (=?UTF-8?B?5bCP6aO8?==Kogai,=?UTF-8?B?IOW8vg==?==
- Dan)
-Subject:
- =?UTF-8?B?IOa8ouWtl+OAgeOCq+OCv+OCq+ODiuOAgeOBsuOCieOBjOOBquOCkuWQq+OCgA==?=
+From: =?UTF-8?B?5bCP6aO8IOW8viA8ZGFua29nYWlAZGFuLmNvLmpwPg==?=
+To: =?UTF-8?B?ZGFua29nYWlAZGFuLmNvLmpwICjlsI/po7w9S29nYWksIOW8vj1EYW4p?=
+Subject: 
+ =?UTF-8?B?5ryi5a2X44CB44Kr44K/44Kr44OK44CB44Gy44KJ44GM44Gq44KS5ZCr44KA?=
  =?UTF-8?B?44CB6Z2e5bi444Gr6ZW344GE44K/44Kk44OI44Or6KGM44GM5LiA5L2T5YWo?=
  =?UTF-8?B?5L2T44Gp44Gu44KI44GG44Gr44GX44GmRW5jb2Rl44GV44KM44KL44Gu44GL?=
  =?UTF-8?B?77yf?=
 EOS
 
 my $qheader=<<'EOS';
-From:=?UTF-8?Q?=20=E5=B0=8F=E9=A3=BC=20=E5=BC=BE=20?=<dankogai@dan.co.jp>
-To: dankogai@dan.co.jp (=?UTF-8?Q?=E5=B0=8F=E9=A3=BC?==Kogai,
- =?UTF-8?Q?=20=E5=BC=BE?==Dan)
-Subject:
- =?UTF-8?Q?=20=E6=BC=A2=E5=AD=97=E3=80=81=E3=82=AB=E3=82=BF=E3=82=AB?=
- =?UTF-8?Q?=E3=83=8A=E3=80=81=E3=81=B2=E3=82=89=E3=81=8C=E3=81=AA=E3=82=92?=
- =?UTF-8?Q?=E5=90=AB=E3=82=80=E3=80=81=E9=9D=9E=E5=B8=B8=E3=81=AB=E9=95=B7?=
- =?UTF-8?Q?=E3=81=84=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E8=A1=8C=E3=81=8C?=
- =?UTF-8?Q?=E4=B8=80=E4=BD=93=E5=85=A8=E4=BD=93=E3=81=A9=E3=81=AE=E3=82=88?=
- =?UTF-8?Q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=A6Encode=E3=81=95?=
- =?UTF-8?Q?=E3=82=8C=E3=82=8B=E3=81=AE=E3=81=8B=EF=BC=9F?=
+From: =?UTF-8?Q?=E5=B0=8F=E9=A3=BC=20=E5=BC=BE=20=3Cdankogai=40?=
+ =?UTF-8?Q?dan=2Eco=2Ejp=3E?=
+To: =?UTF-8?Q?dankogai=40dan=2Eco=2Ejp=20=28?=
+ =?UTF-8?Q?=E5=B0=8F=E9=A3=BC=3DKogai=2C=20=E5=BC=BE=3DDan?= =?UTF-8?Q?=29?=
+Subject: 
+ =?UTF-8?Q?=E6=BC=A2=E5=AD=97=E3=80=81=E3=82=AB=E3=82=BF=E3=82=AB=E3=83=8A?=
+ =?UTF-8?Q?=E3=80=81=E3=81=B2=E3=82=89=E3=81=8C=E3=81=AA=E3=82=92=E5=90=AB?=
+ =?UTF-8?Q?=E3=82=80=E3=80=81=E9=9D=9E=E5=B8=B8=E3=81=AB=E9=95=B7=E3=81=84?=
+ =?UTF-8?Q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E8=A1=8C=E3=81=8C=E4=B8=80?=
+ =?UTF-8?Q?=E4=BD=93=E5=85=A8=E4=BD=93=E3=81=A9=E3=81=AE=E3=82=88=E3=81=86?=
+ =?UTF-8?Q?=E3=81=AB=E3=81=97=E3=81=A6Encode=E3=81=95=E3=82=8C?=
+ =?UTF-8?Q?=E3=82=8B=E3=81=AE=E3=81=8B=EF=BC=9F?=
 EOS
 
 is(Encode::decode('MIME-Header', $bheader), $dheader, "decode B");
@@ -103,8 +103,9 @@ is(Encode::encode('MIME-B', $dheader)."\n", $bheader, "encode B");
 is(Encode::encode('MIME-Q', $dheader)."\n", $qheader, "encode Q");
 
 $dheader = "What is =?UTF-8?B?w4RwZmVs?= ?";
-$bheader = "What is =?UTF-8?B?PT9VVEYtOD9CP3c0UndabVZzPz0=?= ?";
-$qheader = "What is =?UTF-8?Q?=3D=3FUTF=2D8=3FB=3Fw4RwZmVs=3F=3D?= ?";
+$bheader = "=?UTF-8?B?V2hhdCBpcyA9P1VURi04P0I/dzRSd1ptVnM/PSA/?=";
+$qheader = "=?UTF-8?Q?What=20is=20=3D=3FUTF=2D8=3FB=3Fw4R?="
+         . "\n " . "=?UTF-8?Q?wZmVs=3F=3D=20=3F?=";
 is(Encode::encode('MIME-B', $dheader), $bheader, "Double decode B");
 is(Encode::encode('MIME-Q', $dheader), $qheader, "Double decode Q");
 {
@@ -127,5 +128,5 @@ is(Encode::encode('MIME-Q', $rt42627),
    'MIME-Q encoding does not truncate trailing zeros');
 
 # RT87831
-is(Encode::encode('MIME-Header', '0'), '0', 'RT87831');
+is(Encode::encode('MIME-Header', '0'), '=?UTF-8?B?MA==?=', 'RT87831');
 __END__;