[otrs-cvs] otrs/Kernel/cpan-lib/MIME/Field ContType.pm, 1.13, 1.14 ConTraEnc.pm, 1.13, 1.14 ParamVal.pm, 1.13, 1.14 ContDisp.pm, 1.13, 1.14

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/cpan-lib/MIME/Field
In directory lancelot:/tmp/cvs-serv9222/Kernel/cpan-lib/MIME/Field

Modified Files:
	ContType.pm ConTraEnc.pm ParamVal.pm ContDisp.pm 
Log Message:
 - 2013-01-29 Updated CPAN module MIME::Tools to version 5.503, keeping an OTRS patch in MIME::Words.

Author: mg

Index: ContType.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Field/ContType.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -2 -u -d -r1.13 -r1.14
--- ContType.pm	18 Jul 2012 09:46:21 -0000	1.13
+++ ContType.pm	29 Jan 2013 14:37:18 -0000	1.14
@@ -64,5 +64,5 @@
 
 # The package version, both in 1.23 style *and* usable by MakeMaker:
-$VERSION = "5.428";
+$VERSION = "5.503";
 
 # Install it:

Author: mg

Index: ConTraEnc.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Field/ConTraEnc.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -2 -u -d -r1.13 -r1.14
--- ConTraEnc.pm	18 Jul 2012 09:46:21 -0000	1.13
+++ ConTraEnc.pm	29 Jan 2013 14:37:18 -0000	1.14
@@ -48,5 +48,5 @@
 
 # The package version, both in 1.23 style *and* usable by MakeMaker:
-$VERSION = "5.428";
+$VERSION = "5.503";
 
 # Install it:

Author: mg

Index: ParamVal.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Field/ParamVal.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -2 -u -d -r1.13 -r1.14
--- ParamVal.pm	18 Jul 2012 09:46:21 -0000	1.13
+++ ParamVal.pm	29 Jan 2013 14:37:18 -0000	1.14
@@ -1,4 +1,5 @@
 package MIME::Field::ParamVal;
 
+use MIME::Words;
 
 =head1 NAME
@@ -60,8 +61,7 @@
 # Pragmas:
 use strict;
+use re 'taint';
 use vars qw($VERSION @ISA);
 
-# System modules:
-
 
 # Other modules:
@@ -81,5 +81,5 @@
 
 # The package version, both in 1.23 style *and* usable by MakeMaker:
-$VERSION = "5.428";
+$VERSION = "5.503";
 
 
@@ -192,18 +192,17 @@
     my($enc, $lang, $rest);
 
-    if ($val =~ m/^([^\']*)\'([^\']*)\'(.*)$/) {
-	# SHOULD REALLY DO SOMETHING MORE INTELLIGENT WITH ENCODING!!!
+    local($1,$2,$3);
+    if ($val =~ m/^([^']*)'([^']*)'(.*)\z/s) {
 	$enc = $1;
 	$lang = $2;
 	$rest = $3;
-	$rest = rfc2231percent($rest);
-    } elsif ($val =~ m/^([^\']*)\'([^\']*)$/) {
+    } elsif ($val =~ m/^([^']*)'([^']*)\z/s) {
 	$enc = $1;
 	$rest = $2;
-	$rest = rfc2231percent($rest);
     } else {
-	$rest = rfc2231percent($val);
+	$rest = $val;
+	# $enc remains undefined when charset/language info is missing
     }
-    return $rest;
+    return ($enc, $lang, $rest);
 }
 
@@ -211,4 +210,5 @@
     # Do percent-subsitution
     my($str) = @_;
+    local $1;
     $str =~ s/%([0-9a-fA-F]{2})/pack("C", hex($1))/ge;
     return $str;
@@ -217,6 +217,7 @@
 sub parse_params {
     my ($self, $raw) = @_;
-    my %params = ();
-    my %rfc2231params = ();
+    my %params;
+    my %rfc2231params;
+    my %rfc2231encoding_is_used;
     my $param;
     my $val;
@@ -226,6 +227,7 @@
     defined($raw) or $raw = '';
     $raw =~ s/\n//g;
-    $raw =~ s/\s+$//;              # Strip trailing whitespace
+    $raw =~ s/\s+\z//;              # Strip trailing whitespace
 
+    local($1,$2,$3,$4,$5);
     # Extract special first parameter:
     $raw =~ m/\A$SPCZ($FIRST)$SPCZ/og or return {};    # nada!
@@ -238,10 +240,10 @@
 	$raw =~ m/\G($PARAMNAME)\s*=\s*/og or last;      # give up if not a param
 	$param = lc($1);
-	$raw =~ m/\G(\"([^\"]*)\")|\G($ENCTOKEN)|\G($BADTOKEN)|\G($TOKEN)/g or last;   # give up if no value"
+	$raw =~ m/\G(?:("([^"]*)")|($ENCTOKEN)|($BADTOKEN)|($TOKEN))/g or last;   # give up if no value"
 	my ($qstr, $str, $enctoken, $badtoken, $token) = ($1, $2, $3, $4, $5);
 	if (defined($badtoken)) {
 	    # Strip leading/trailing whitespace from badtoken
-	    $badtoken =~ s/^\s*//;
-	    $badtoken =~ s/\s*$//;
+	    $badtoken =~ s/^\s+//;
+	    $badtoken =~ s/\s+\z//;
 	}
 	$val = defined($qstr) ? $str :
@@ -250,20 +252,16 @@
 
 	# Do RFC 2231 processing
-	if ($param =~ /\*/) {
-	    my($name, $num);
-	    # Pick out the parts of the parameter
-	    if ($param =~ m/^([^*]+)\*([^*]+)\*?$/) {
-		# We have param*number* or param*number
-		$name = $1;
-		$num = $2;
-	    } else {
-		# Fake a part of zero... not sure how to handle this properly
-		$param =~ s/\*//g;
-		$name = $param;
-		$num = 0;
-	    }
-	    # Decode the value unless it was a quoted string
-	    if (!defined($qstr)) {
-		$val = rfc2231decode($val);
+	# Pick out the parts of the parameter
+	if ($param =~ /\*/ &&
+            $param =~ /^ ([^*]+) (?: \* ([^*]+) )? (\*)? \z/xs) {
+	    # We have param*number* or param*number or param*
+	    my($name, $num) = ($1, $2||0);
+	    if (defined($3)) {
+		# We have param*number* or param*
+		# RFC 2231: Asterisks ("*") are reused to provide the
+		# indicator that language and character set information
+		# is present and encoding is being used
+		$val = rfc2231percent($val);
+		$rfc2231encoding_is_used{$name} = 1;
 	    }
 	    $rfc2231params{$name}{$num} .= $val;
@@ -285,4 +283,16 @@
 	    $params{$param} .= $rfc2231params{$param}{$part};
 	}
+	if ($rfc2231encoding_is_used{$param}) {
+	    my($enc, $lang, $val) = rfc2231decode($params{$param});
+	    if (defined $enc) {
+		# re-encode as QP, preserving charset and language info
+		$val =~ s{([=?_\x00-\x1F\x7F-\xFF])}
+			 {sprintf("=%02X", ord($1))}eg;
+		$val =~ tr/ /_/;
+		# RFC 2231 section 5: Language specification in Encoded Words
+		$enc .= '*' . $lang  if defined $lang && $lang ne '';
+		$params{$param} = '=?' . $enc . '?Q?' . $val . '?=';
+	    }
+	}
 	debug "   field param <$param> = <$params{$param}>";
     }

Author: mg

Index: ContDisp.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Field/ContDisp.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -2 -u -d -r1.13 -r1.14
--- ContDisp.pm	18 Jul 2012 09:46:21 -0000	1.13
+++ ContDisp.pm	29 Jan 2013 14:37:18 -0000	1.14
@@ -49,5 +49,5 @@
 
 # The package version, both in 1.23 style *and* usable by MakeMaker:
-$VERSION = "5.428";
+$VERSION = "5.503";
 
 # Install it:
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.