r68646 - in /branches/upstream/libencode-imaputf7-perl: ./ current/ current/lib/ current/lib/Encode/ current/t/

takaki at users.alioth.debian.org takaki at users.alioth.debian.org
Tue Feb 15 04:37:05 UTC 2011


Author: takaki
Date: Tue Feb 15 04:36:56 2011
New Revision: 68646

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=68646
Log:
[svn-inject] Installing original source of libencode-imaputf7-perl (1.05)

Added:
    branches/upstream/libencode-imaputf7-perl/
    branches/upstream/libencode-imaputf7-perl/current/
    branches/upstream/libencode-imaputf7-perl/current/Changes
    branches/upstream/libencode-imaputf7-perl/current/INSTALL
    branches/upstream/libencode-imaputf7-perl/current/MANIFEST
    branches/upstream/libencode-imaputf7-perl/current/META.yml
    branches/upstream/libencode-imaputf7-perl/current/Makefile.PL
    branches/upstream/libencode-imaputf7-perl/current/README
    branches/upstream/libencode-imaputf7-perl/current/lib/
    branches/upstream/libencode-imaputf7-perl/current/lib/Encode/
    branches/upstream/libencode-imaputf7-perl/current/lib/Encode/IMAPUTF7.pm
    branches/upstream/libencode-imaputf7-perl/current/t/
    branches/upstream/libencode-imaputf7-perl/current/t/0-test.t
    branches/upstream/libencode-imaputf7-perl/current/t/1-ampersand.t
    branches/upstream/libencode-imaputf7-perl/current/t/ksc5601.utf   (with props)

Added: branches/upstream/libencode-imaputf7-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/Changes?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/Changes (added)
+++ branches/upstream/libencode-imaputf7-perl/current/Changes Tue Feb 15 04:36:56 2011
@@ -1,0 +1,30 @@
+Revision history for Perl extension Encode::IMAPUTF7.
+
+1.05 - Fri Jun 18 12:28:40 2010
+	Correct handling of bad data (rt: #57984)
+
+1.04	2009-04-30
+    Revised the revision history
+    (see http://peter.makholm.net/2009/04/30/i-broke-encode-imaputf7/)
+
+1.03    2009-04-21
+    Version 1.02 introduced more bugs than it fixed:
+    - '&' was errounous encoded with '&_' instead of '&-'
+    - A '&' following characters to be encoded was stil base64 encoded instead
+      of being encoded as '&-'
+
+1.02    2009-04-20
+    Code tidying
+    Make encoding more compliant to the RFC (rt: #<removed>)
+    - thanks to <name removed>
+
+1.01    2009-02-17
+    Release as non-developers release
+
+1.00_01 2009-02-16
+    Silence warnings from decode() (rt: #36180)
+    Make it work with perl 5.10 (rt: #40827)
+
+1.00  Wed Sep 28 2005
+      original version
+

Added: branches/upstream/libencode-imaputf7-perl/current/INSTALL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/INSTALL?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/INSTALL (added)
+++ branches/upstream/libencode-imaputf7-perl/current/INSTALL Tue Feb 15 04:36:56 2011
@@ -1,0 +1,16 @@
+To compile
+
+	perl Makefile.PL
+	make
+	make test
+
+To install
+
+	make install
+
+To add IMAP-UTF-7 to Encode's demand-loading list (so you don't have to 
+"use Encode::IMAPUTF7" but the plain "use Encode"), after install run
+
+        enc2xs -C
+
+        

Added: branches/upstream/libencode-imaputf7-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/MANIFEST?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/MANIFEST (added)
+++ branches/upstream/libencode-imaputf7-perl/current/MANIFEST Tue Feb 15 04:36:56 2011
@@ -1,0 +1,10 @@
+Changes
+INSTALL
+lib/Encode/IMAPUTF7.pm
+Makefile.PL
+MANIFEST			This list of files
+README
+t/0-test.t
+t/1-ampersand.t
+t/ksc5601.utf
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libencode-imaputf7-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/META.yml?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/META.yml (added)
+++ branches/upstream/libencode-imaputf7-perl/current/META.yml Tue Feb 15 04:36:56 2011
@@ -1,0 +1,23 @@
+--- #YAML:1.0
+name:               Encode-IMAPUTF7
+version:            1.05
+abstract:           modification of UTF-7 encoding for IMAP
+author:
+    - Peter Makholm <peter at makholm.net>
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Encode:            0
+    Test::NoWarnings:  0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.55_02
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Added: branches/upstream/libencode-imaputf7-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/Makefile.PL?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/Makefile.PL (added)
+++ branches/upstream/libencode-imaputf7-perl/current/Makefile.PL Tue Feb 15 04:36:56 2011
@@ -1,0 +1,15 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    'NAME'	=> 'Encode::IMAPUTF7',
+    'VERSION_FROM' => 'lib/Encode/IMAPUTF7.pm',    
+    'dist'          => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    ($] >= 5.005 ?
+      (ABSTRACT_FROM  => 'lib/Encode/IMAPUTF7.pm',
+       AUTHOR         => 'Peter Makholm <peter at makholm.net>') : ()),
+    PREREQ_PM      => {
+        'Encode'           => 0,  # In core since 5.7.3
+        'Test::NoWarnings' => 0,
+    }
+);

Added: branches/upstream/libencode-imaputf7-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/README?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/README (added)
+++ branches/upstream/libencode-imaputf7-perl/current/README Tue Feb 15 04:36:56 2011
@@ -1,0 +1,18 @@
+NAME
+    Encode::Unicode::IMAPUTF7 - Perl extension to deal with UTF-7 modification for IMAP
+
+DESCRIPTION
+    IMAP mailbox names are encoded in a modified UTF-7 when names contains
+    international characters outside of the printable ASCII range. The
+    modified UTF-7 encoding is defined in RFC2060 (section 5.1.3).
+
+COPYRIGHT
+    Copyright 2005
+
+    Sava Chankov, sava at cpan.org
+
+    This software may be freely copied and distributed under the same
+    terms and conditions as Perl.
+
+SEE ALSO
+    perl(1), Encode.

Added: branches/upstream/libencode-imaputf7-perl/current/lib/Encode/IMAPUTF7.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/lib/Encode/IMAPUTF7.pm?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/lib/Encode/IMAPUTF7.pm (added)
+++ branches/upstream/libencode-imaputf7-perl/current/lib/Encode/IMAPUTF7.pm Tue Feb 15 04:36:56 2011
@@ -1,0 +1,180 @@
+#
+# $Id: IMAPUTF7.pm 3398 2009-04-21 13:18:16Z makholm $
+#
+package Encode::IMAPUTF7;
+use strict;
+no warnings 'redefine';
+use base qw(Encode::Encoding);
+__PACKAGE__->Define('IMAP-UTF-7', 'imap-utf-7');
+our $VERSION = '1.05';
+use MIME::Base64;
+use Encode;
+
+#
+# Algorithms taken from Unicode::String by Gisle Aas
+# Code directly borrowed from Encode::Unicode::UTF7 by Dan Kogai
+#
+
+# Directly from the definition in RFC2060:
+# Ampersand (\x26) is represented as a special case
+my $re_asis =     qr/(?:[\x20-\x25\x27-\x7e])/; # printable US-ASCII except "&" represents itself
+my $re_encoded = qr/(?:[^\x20-\x7e])/; # Everything else are represented by modified base64
+
+my $e_utf16 = find_encoding("UTF-16BE");
+
+sub needs_lines { 1 };
+
+sub encode($$;$) {
+    my ( $obj, $str, $chk ) = @_;
+    my $len = length($str);
+    pos($str) = 0;
+    my $bytes = '';
+    while ( pos($str) < $len ) {
+        if ( $str =~ /\G($re_asis+)/ogc ) {
+            $bytes .= $1;
+        } elsif ( $str =~ /\G&/ogc ) {
+            $bytes .= "&-";
+        } elsif ( $str =~ /\G($re_encoded+)/ogsc ) {
+            my $s = $1;
+            my $base64 = encode_base64( $e_utf16->encode($s), '' );
+            $base64 =~ s/=+$//;
+            $base64 =~ s/\//,/g;
+            $bytes .= "&$base64-";
+        } else {
+            die "This should not happen! (pos=" . pos($str) . ")";
+        }
+    }
+    $_[1] = '' if $chk;
+    return $bytes;
+}
+
+sub decode($$;$) {
+    my ( $obj, $bytes, $chk ) = @_;
+    my $len = length($bytes);
+    my $str = "";
+    pos($bytes) = 0;
+    while ( pos($bytes) < $len ) {
+        if ( $bytes =~ /\G([^&]+)/ogc ) {
+            $str .= $1;
+        } elsif ( $bytes =~ /\G\&-/ogc ) {
+            $str .= "&";
+        } elsif ( $bytes =~ /\G\&([A-Za-z0-9+,]+)-?/ogsc ) {
+            my $base64 = $1;
+            $base64 =~ s/,/\//g;
+            my $pad = length($base64) % 4;
+            $base64 .= "=" x ( 4 - $pad ) if $pad;
+            $str .= $e_utf16->decode( decode_base64($base64) );
+        } elsif ( $bytes =~ /\G\&/ogc ) {
+            $^W and warn "Bad IMAP-UTF7 data escape";
+            $str .= "&";
+        } else {
+            die "This should not happen " . pos($bytes);
+        }
+    }
+    $_[1] = '' if $chk;
+    return $str;
+}
+
+
+1;
+__END__
+
+=head1 NAME
+
+Encode::IMAPUTF7 - modification of UTF-7 encoding for IMAP
+
+=head1 SYNOPSIS
+
+  use Encode qw/encode decode/;
+
+  print encode('IMAP-UTF-7', 'Répertoire');
+  print decode('IMAP-UTF-7', R&AOk-pertoire');
+
+=head1 ABSTRACT
+
+IMAP mailbox names are encoded in a modified UTF7 when names contains 
+international characters outside of the printable ASCII range. The
+modified UTF-7 encoding is defined in RFC2060 (section 5.1.3).
+
+There is another CPAN module with same purpose, Unicode::IMAPUtf7. However, it
+works correctly only with strings, which encoded form does not
+contain plus sign. For example, the Cyrillic string
+\x{043f}\x{0440}\x{0435}\x{0434}\x{043b}\x{043e}\x{0433} is represented in UTF-7 as
++BD8EQAQ1BDQEOwQ+BDM- Note the second plus sign 4 characters before the end. 
+Unicode::IMAPUtf7 encodes the above string as +BD8EQAQ1BDQEOwQ&BDM- 
+which is not valid modified UTF-7 (the ampersand and
+the plus are swapped). The problem is solved by the current module,
+which is slightly modified Encode::Unicode::UTF7 and has nothing common with
+Unicode::IMAPUtf7.
+
+=head1 RFC2060 - section 5.1.3 - Mailbox International Naming Convention
+
+By convention, international mailbox names are specified using a
+modified version of the UTF-7 encoding described in [UTF-7].  The
+purpose of these modifications is to correct the following problems
+with UTF-7:
+
+1) UTF-7 uses the "+" character for shifting; this conflicts with
+   the common use of "+" in mailbox names, in particular USENET
+   newsgroup names.
+
+2) UTF-7's encoding is BASE64 which uses the "/" character; this
+   conflicts with the use of "/" as a popular hierarchy delimiter.
+
+3) UTF-7 prohibits the unencoded usage of "\"; this conflicts with
+   the use of "\" as a popular hierarchy delimiter.
+
+4) UTF-7 prohibits the unencoded usage of "~"; this conflicts with
+   the use of "~" in some servers as a home directory indicator.
+
+5) UTF-7 permits multiple alternate forms to represent the same
+   string; in particular, printable US-ASCII chararacters can be
+   represented in encoded form.
+
+In modified UTF-7, printable US-ASCII characters except for "&"
+represent themselves; that is, characters with octet values 0x20-0x25
+and 0x27-0x7e.  The character "&" (0x26) is represented by the two-
+octet sequence "&-".
+
+All other characters (octet values 0x00-0x1f, 0x7f-0xff, and all
+Unicode 16-bit octets) are represented in modified BASE64, with a
+further modification from [UTF-7] that "," is used instead of "/".
+Modified BASE64 MUST NOT be used to represent any printing US-ASCII
+character which can represent itself.
+
+"&" is used to shift to modified BASE64 and "-" to shift back to US-
+ASCII.  All names start in US-ASCII, and MUST end in US-ASCII (that
+is, a name that ends with a Unicode 16-bit octet MUST end with a "-
+").
+
+For example, here is a mailbox name which mixes English, Japanese,
+and Chinese text: ~peter/mail/&ZeVnLIqe-/&U,BTFw-
+
+=head1 REQUESTS & BUGS
+
+Please report any requests, suggestions or bugs via the RT bug-tracking system 
+at http://rt.cpan.org/ or email to bug-Encode-IMAPUTF7 at rt.cpan.org. 
+
+http://rt.cpan.org/NoAuth/Bugs.html?Dist=Encode-IMAPUTF7 is the RT queue for Encode::IMAPUTF7.
+Please check to see if your bug has already been reported. 
+
+=head1 COPYRIGHT
+
+Copyright 2005 Sava Chankov
+
+Sava Chankov, sava at cpan.org
+
+This software may be freely copied and distributed under the same
+terms and conditions as Perl.
+
+=head1 AUTHORS
+
+Peter Makholm E<lt>peter at makholm.netE<gt>, current maintainer
+
+Sava Chankov E<lt>sava at cpan.orgE<gt>, original author
+
+=head1 SEE ALSO
+
+perl(1), Encode.
+
+=cut

Added: branches/upstream/libencode-imaputf7-perl/current/t/0-test.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/t/0-test.t?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/t/0-test.t (added)
+++ branches/upstream/libencode-imaputf7-perl/current/t/0-test.t Tue Feb 15 04:36:56 2011
@@ -1,0 +1,35 @@
+# $Id: 0-test.t 3398 2009-04-21 13:18:16Z makholm $
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::NoWarnings;
+
+use Encode::IMAPUTF7 qw(encode decode);
+
+use File::Spec;
+use File::Basename;
+
+my $dir =  dirname(__FILE__);
+opendir my $dh, $dir or die "$dir:$!";
+my @file = sort grep {/\.utf$/o} readdir $dh;
+closedir $dh;
+for my $file (@file){
+    my $path = File::Spec->catfile($dir, $file);
+    open my $fh, '<', $path or die "$path:$!";
+    my $content;
+    if (PerlIO::Layer->find('perlio')){
+	binmode $fh => ':utf8';
+	$content = join('' => <$fh>);
+    }else{ # ugh!
+	binmode $fh;
+	$content = join('' => <$fh>);
+	Encode::_utf8_on($content)
+    }
+    close $fh;
+    is(Encode::decode("IMAP-UTF-7", Encode::encode("IMAP-UTF-7", $content)), $content, 
+       "IMAP-UTF-7 RT:$file");
+}
+1;
+__END__

Added: branches/upstream/libencode-imaputf7-perl/current/t/1-ampersand.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/t/1-ampersand.t?rev=68646&op=file
==============================================================================
--- branches/upstream/libencode-imaputf7-perl/current/t/1-ampersand.t (added)
+++ branches/upstream/libencode-imaputf7-perl/current/t/1-ampersand.t Tue Feb 15 04:36:56 2011
@@ -1,0 +1,18 @@
+#!/usr/bin/perl
+# $Id: 1-ampersand.t 3398 2009-04-21 13:18:16Z makholm $
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+use Test::NoWarnings;
+
+use Encode::IMAPUTF7 qw(encode decode);
+
+is(Encode::IMAPUTF7->encode("&"), "&-", "Single ampersand");
+is(Encode::IMAPUTF7->encode("A&B"), "A&-B", "Ampersand surrounded by two US-ASCII chars");
+is(Encode::IMAPUTF7->encode("A&\x{C5}"), "A&-&AMU-", "Ampersand surrounded by US-ASCII char and 8bit char");
+is(Encode::IMAPUTF7->encode("\x{C5}&B"), "&AMU-&-B", "Ampersand surrounded by 8bit char and US-ASCII char");
+is(Encode::IMAPUTF7->encode("\x{D8}&\x{C5}"), "&ANg-&-&AMU-", "Ampersand surrounded by two 8bit chars");
+
+

Added: branches/upstream/libencode-imaputf7-perl/current/t/ksc5601.utf
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libencode-imaputf7-perl/current/t/ksc5601.utf?rev=68646&op=file
==============================================================================
Binary file - no diff available.

Propchange: branches/upstream/libencode-imaputf7-perl/current/t/ksc5601.utf
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream




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