[Rt-commit] r3619 - in rt/branches/3.5-TESTING: . html/Ticket/Elements

trs at bestpractical.com trs at bestpractical.com
Sun Aug 7 11:49:20 EDT 2005


Author: trs
Date: Sun Aug  7 11:49:20 2005
New Revision: 3619

Modified:
   rt/branches/3.5-TESTING/   (props changed)
   rt/branches/3.5-TESTING/html/Ticket/Elements/ShowMessageHeaders
Log:
 r5714 at wintermute:  tom | 2005-08-07 11:46:58 -0400
 * Fixed parsing of message headers (though maybe we shoud
   use an established module to do this?)
 
 * Cleaned up the component a little


Modified: rt/branches/3.5-TESTING/html/Ticket/Elements/ShowMessageHeaders
==============================================================================
--- rt/branches/3.5-TESTING/html/Ticket/Elements/ShowMessageHeaders	(original)
+++ rt/branches/3.5-TESTING/html/Ticket/Elements/ShowMessageHeaders	Sun Aug  7 11:49:20 2005
@@ -43,14 +43,15 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-% use Data::Dumper;
 <table>
 % foreach my $header (@headers) {
-% next unless ($display_headers{'_all'} || $display_headers{lc($header->{'Tag'})});
-<tr>
-<td align="right" class="message-header-key"><%$header->{'Tag'}%>:</td>
-<td class="message-header-value"><%$header->{'Value'} | n%></td>
-</tr>
+%     next unless $display_headers{_all}
+%           or ($display_headers{ lc $header->{Tag} }
+%                 and length $header->{Value});
+  <tr>
+    <td align="right" class="message-header-key"><%$header->{'Tag'}%>:</td>
+    <td class="message-header-value"><%$header->{'Value'} | n%></td>
+  </tr>
 % }
 </table>
 <%INIT>
@@ -61,23 +62,24 @@
 # we'll display the value without escaping later (for MakeClicky et al.)
 $content = $m->interp->apply_escapes($content, 'h');
 
-my @lines = split (/\n/,$content);
+my @lines = split /\n/, $content;
 my $in_header = 0;
-my @headers =();
-foreach (@lines) {
+my @headers;
+
+for (@lines) {
     if (/^(\S+):\s+(.*)$/) {
-        push (@headers, { Tag => $1, Value => $2} ); 
-    } elsif ($headers[-1]) {
+        push @headers, { Tag => $1, Value => $2 };
+    }
+    elsif (/^\s+/) {
         $headers[-1]->{'Value'} .= $_;
-    } else {
-
-        push (@headers, { Tag => $_, Value => ''} ); 
+    }
+    else {
+        s/:$//;
+        push @headers, { Tag => $_, Value => '' };
     }
 }
 
-my %display_headers;
-
-map { $display_headers{lc($_)} = 1 } @$DisplayHeaders;
+my %display_headers = map { lc($_) => 1 } @$DisplayHeaders;
 
 $m->comp('/Elements/Callback', _CallbackName => 'Headers', content => \$content, headers => \@headers, display_headers => \%display_headers, %ARGS);
 


More information about the Rt-commit mailing list