From cc5a9e5962147c693480c7774dcdfdc2ca1b440a Mon Sep 17 00:00:00 2001
From: Robert Scheck <rob...@fedoraproject.org>
Date: Thu, 23 Mar 2017 18:44:53 +0100
Subject: backported upstream patch from 1.928 to update subparts in walk_parts
 if stringification changes

---
 perl-Email-MIME-1.926-walk_parts.patch | 41 ++++++++++++++++++++++++++++++++++
 perl-Email-MIME.spec                   |  8 ++++++-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 perl-Email-MIME-1.926-walk_parts.patch

diff --git a/perl-Email-MIME-1.926-walk_parts.patch 
b/perl-Email-MIME-1.926-walk_parts.patch
new file mode 100644
index 0000000..c379ed2
--- /dev/null
+++ b/perl-Email-MIME-1.926-walk_parts.patch
@@ -0,0 +1,41 @@
+Backported patch to update subparts in walk_parts if stringification changes, 
taken from
+a unified diff between Email::MIME 1.926 and 1.928. The regression was 
introduced somewhen
+between Email::MIME 1.910 and 1.926 and results in a "non-working" as_string() 
method due
+to a broken walk_parts() method. While the as_string() method doesn't 
obviously fail, it
+however returns the old content and not the new, changed content though. An 
example of how
+the regression looks like is described at:
+
+https://stackoverflow.com/questions/22035883/how-to-change-the-body-of-one-part-using-emailmime-or-who-does-body-set-work
+
+The important point is, that the workaround mentioned in the first answer 
using parts_set()
+method only works for some cases, however not for e-mails being 
multipart/mixed (which e.g.
+would be an e-mail with multipart/alternative, thus text and html, with an 
attachment)!
+
+--- Email-MIME-1.926/lib/Email/MIME.pm                 2014-01-29 
05:28:45.000000000 +0100
++++ Email-MIME-1.926/lib/Email/MIME.pm.walk_parts      2017-03-23 
17:02:56.000000000 +0100
+@@ -731,11 +731,20 @@
+     $callback->($part);
+ 
+     if (my @orig_subparts = $part->subparts) {
+-      my @subparts = map {; $walk->($_) } @orig_subparts;
+-      my $differ
+-        =  (@subparts != @orig_subparts)
+-        || (grep { $subparts[$_] != $orig_subparts[$_] } (0 .. $#subparts))
+-        || (grep { $changed{ 0+$subparts[$_] } } (0 .. $#subparts));
++      my $differ;
++      my @subparts;
++
++      for my $part (@orig_subparts) {
++        my $str = $part->as_string;
++        next unless my $new = $walk->($part);
++        $differ = 1 if $str ne $new->as_string;
++        push @subparts, $new;
++      }
++
++      $differ
++        ||=  (@subparts != @orig_subparts)
++        ||   (grep { $subparts[$_] != $orig_subparts[$_] } (0 .. $#subparts))
++        ||   (grep { $changed{ 0+$subparts[$_] } } (0 .. $#subparts));
+ 
+       if ($differ) {
+         $part->parts_set(\@subparts);
diff --git a/perl-Email-MIME.spec b/perl-Email-MIME.spec
index cb657c4..3948c13 100644
--- a/perl-Email-MIME.spec
+++ b/perl-Email-MIME.spec
@@ -1,12 +1,13 @@
 Name:           perl-Email-MIME
 Version:        1.926
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Easy MIME message parsing
 
 Group:          Development/Libraries
 License:        GPL+ or Artistic
 URL:            http://search.cpan.org/dist/Email-MIME/
 Source0:        
http://www.cpan.org/authors/id/R/RJ/RJBS/Email-MIME-%{version}.tar.gz
+Patch0:         perl-Email-MIME-1.926-walk_parts.patch
 
 BuildArch:      noarch
 # Module Build
@@ -53,6 +54,7 @@ parts of the message. Headers are decoded from MIME encoding.
 
 %prep
 %setup -q -n Email-MIME-%{version}
+%patch0 -p1 -b .walk_parts
 
 
 %build
@@ -79,6 +81,10 @@ make test TEST_FILES="$(echo $(find xt/ -name '*.t'))"
 
 
 %changelog
+* Thu Mar 23 2017 Robert Scheck <rob...@fedoraproject.org> - 1.926-2
+- backported upstream patch from 1.928 to update subparts in
+  walk_parts if stringification changes
+
 * Thu Mar  6 2014 Tom Callaway <s...@fedoraproject.org> - 1.926-1
 - update to 1.926
 
-- 
cgit v1.1


        
https://src.fedoraproject.org/cgit/perl-Email-MIME.git/commit/?h=epel7&id=cc5a9e5962147c693480c7774dcdfdc2ca1b440a
_______________________________________________
perl-devel mailing list -- perl-devel@lists.fedoraproject.org
To unsubscribe send an email to perl-devel-le...@lists.fedoraproject.org

Reply via email to