[otrs-cvs] otrs/Kernel/cpan-lib/MIME/Parser Filer.pm, 1.9, 1.10 Reader.pm, 1.7, 1.8

"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/Parser
In directory lancelot:/tmp/cvs-serv9222/Kernel/cpan-lib/MIME/Parser

Modified Files:
	Filer.pm Reader.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: Filer.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Parser/Filer.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -2 -u -d -r1.9 -r1.10
--- Filer.pm	18 Jul 2012 09:46:21 -0000	1.9
+++ Filer.pm	29 Jan 2013 14:37:18 -0000	1.10
@@ -35,5 +35,5 @@
 =head2 Semi-public interface
 
-These methods might be overriden or ignored in some subclasses,
+These methods might be overridden or ignored in some subclasses,
 so they don't all make sense in all circumstances:
 
@@ -328,5 +328,6 @@
 in generating a disk file name?  It is if any of these are true:
 
-    * it is empty
+    * it is empty or entirely whitespace
+    * it contains leading or trailing whitespace
     * it is a string of dots: ".", "..", etc.
     * it contains characters not in the set: "A" - "Z", "a" - "z",
@@ -396,5 +397,11 @@
 
     ### Isolate to last path element:
-    my $last = $fname; $last =~ s{^.*[/\\\[\]:]}{};
+    my $last = $fname;
+
+    ### Path separators are / or \
+    $last =~ s{^.*[/\\]}{};
+
+    ### Convert semi-evil characters to underscores
+    $last =~ s/[\/\\\[\]:]/_/g;
     if ($last and !$self->evil_filename($last)) {
 	$self->debug("looks like I can use the last path element");
@@ -531,5 +538,5 @@
 
     ### Get the recommended name:
-    my $recommended = unmime $head->recommended_filename;
+    my $recommended = $head->recommended_filename;
 
     ### Get content type:
@@ -656,6 +663,6 @@
     my $dir = $self->output_dir($head);
 
-    ### Get the output filename, decoding into the local character set:
-    my $fname = unmime $head->recommended_filename;
+    ### Get the output filename as UTF-8
+    my $fname = $head->recommended_filename;
 
     ### Can we use it:

Author: mg

Index: Reader.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/MIME/Parser/Reader.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -2 -u -d -r1.7 -r1.8
--- Reader.pm	18 Jul 2012 09:46:21 -0000	1.7
+++ Reader.pm	29 Jan 2013 14:37:18 -0000	1.8
@@ -35,5 +35,4 @@
 
 use strict;
-use IO::ScalarArray;
 
 ### All possible end-of-line sequences.
@@ -185,5 +184,5 @@
 sub native_handle {
     my $fh = shift;
-    return $fh if $fh->isa('IO::File');
+    return $fh if ($fh->isa('IO::File') || $fh->isa('IO::Handle'));
     return $fh if (ref $fh eq 'GLOB');
     undef;
@@ -207,5 +206,5 @@
 # the boundary is part of the boundary, NOT part of the input!
 #
-# NOTE: while parsing, we take care to remember the EXACT end-of-line
+# NOTE: while parsing bodies, we take care to remember the EXACT end-of-line
 # sequence.  This is because we *may* be handling 'binary' encoded data, and
 # in that case we can't just massage \r\n into \n!  Don't worry... if the
@@ -219,6 +218,11 @@
 
 sub read_chunk {
-    my ($self, $in, $out) = @_;
+    my ($self, $in, $out, $keep_newline, $normalize_newlines) = @_;
+
+    # If we're parsing a preamble or epilogue, we need to keep the blank line
+    # that precedes the boundary line.
+    $keep_newline ||= 0;
 
+    $normalize_newlines ||= 0;
     ### Init:
     my %bh = %{$self->{BH}};
@@ -237,4 +241,6 @@
 	if ($n_out) {            ### native input, native output [fastest]
 	    while (<$n_in>) {
+		# Normalize line ending
+		$_ =~ s/(:?\n\r|\r\n|\r)$/\n/ if $normalize_newlines;
 		if (substr($_, 0, 2) eq '--') {
 		    ($maybe = $_) =~ s/[ \t\r\n]+\Z//;
@@ -247,4 +253,6 @@
 	else {                   ### native input, OO output [slower]
 	    while (<$n_in>) {
+		# Normalize line ending
+		$_ =~ s/(:?\n\r|\r\n|\r)$/\n/ if $normalize_newlines;
 		if (substr($_, 0, 2) eq '--') {
 		    ($maybe = $_) =~ s/[ \t\r\n]+\Z//;
@@ -259,4 +267,6 @@
 	if ($n_out) {            ### OO input, native output [even slower]
 	    while (defined($_ = $in->getline)) {
+		# Normalize line ending
+		$_ =~ s/(:?\n\r|\r\n|\r)$/\n/ if $normalize_newlines;
 		if (substr($_, 0, 2) eq '--') {
 		    ($maybe = $_) =~ s/[ \t\r\n]+\Z//;
@@ -269,4 +279,6 @@
 	else {                   ### OO input, OO output [slowest]
 	    while (defined($_ = $in->getline)) {
+		# Normalize line ending
+		$_ =~ s/(:?\n\r|\r\n|\r)$/\n/ if $normalize_newlines;
 		if (substr($_, 0, 2) eq '--') {
 		    ($maybe = $_) =~ s/[ \t\r\n]+\Z//;
@@ -279,6 +291,8 @@
     }
 
-    ### Write out last held line, removing terminating CRLF if ended on bound:
-    $last =~ s/[\r\n]+\Z// if ($eos =~ /^(DELIM|CLOSE)/);
+    # Write out last held line, removing terminating CRLF if ended on bound,
+    # unless the line consists only of CRLF and we're wanting to keep the
+    # preceding blank line (as when parsing a preamble)
+    $last =~ s/[\r\n]+\Z// if ($eos =~ /^(DELIM|CLOSE)/ && !($keep_newline && $last =~ m/^[\r\n]\z/));
     $out->print($last);
 
@@ -297,7 +311,11 @@
 sub read_lines {
     my ($self, $in, $outlines) = @_;
-    # TODO: we are also stuck keeping this one for now
-    $self->read_chunk($in, IO::ScalarArray->new($outlines));
-    shift @$outlines if ($outlines->[0] eq '');   ### leading empty line
+
+    my $data = '';
+    open(my $fh, '>', \$data) or die $!;
+    $self->read_chunk($in, $fh);
+    @$outlines =  split(/^/, $data);
+    close $fh;
+
     1;
 }
---------------------------------------------------------------------
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.