[interchange] Fix crash in [email] tag with two attachments, e.g.

Stefan Hornburg <[email protected]>
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit 60ddcfefe3c2477bffe5d9da8da555154d51aa10
Author: Stefan Hornburg (Racke) <[email protected]>
Date:   Fri Nov 12 21:35:55 2010 +0100

    Fix crash in [email] tag with two attachments, e.g.
    
    [email
       to="Ton Verhagen <[email protected]>"
       from="Foobar <[email protected]>"
       subject="Email with an attachment"
       attach.0="images/test1.png"
       attach.1="images/test2.png"
    
    ]This email has two attachments.[/email]

 code/UserTag/email.tag |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/code/UserTag/email.tag b/code/UserTag/email.tag
index 97b3e9a..c4c9c73 100644
--- a/code/UserTag/email.tag
+++ b/code/UserTag/email.tag
@@ -146,6 +146,21 @@ sub {
 		elsif(ref($att) eq 'HASH') {
 			$att = [ $att ];
 		}
+		elsif(ref($att) eq 'ARRAY') {
+			# turn array of file names into array of hash references
+			my $new_att = [];
+
+			for (@$att) {
+				if (ref($_)) {
+					push (@$new_att, $_);
+				}
+				else {
+					push (@$new_att, {path => $_});
+				}
+			}
+
+			$att = $new_att;
+		}
 
 		$att ||= [];
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.