[Rt-commit] [svn] r742 - rt/trunk/lib/RT
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Mon Apr 26 14:57:29 EDT 2004
Author: jesse
Date: Mon Apr 26 14:57:29 2004
New Revision: 742
Modified:
rt/trunk/lib/RT/Attachment_Overlay.pm
Log:
RT previously split stored headers on newlines. The new regexp better matches what the RFC says it should
Modified: rt/trunk/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/trunk/lib/RT/Attachment_Overlay.pm (original)
+++ rt/trunk/lib/RT/Attachment_Overlay.pm Mon Apr 26 14:57:29 2004
@@ -459,7 +459,7 @@
sub Headers {
my $self = shift;
my $hdrs="";
- for (split(/\n/,$self->SUPER::Headers)) {
+ for ($self->_SplitHeaders) {
$hdrs.="$_\n" unless /^(RT-Send-Bcc): /i
}
return $hdrs;
@@ -480,7 +480,7 @@
sub GetHeader {
my $self = shift;
my $tag = shift;
- foreach my $line (split(/\n/,$self->SUPER::Headers)) {
+ foreach my $line ($self->_SplitHeaders) {
if ($line =~ /^\Q$tag\E:\s+(.*)$/i) { #if we find the header, return its value
return ($1);
}
@@ -504,7 +504,7 @@
my $tag = shift;
my $newheader = '';
- foreach my $line (split(/\n/,$self->SUPER::Headers)) {
+ foreach my $line ($self->_SplitHeaders) {
if (defined $tag and $line =~ /^\Q$tag\E:\s+(.*)$/i) {
$newheader .= "$tag: $_[0]\n";
undef $tag;
@@ -557,6 +557,54 @@
# }}}
+=head2 _SplitHeaders
+
+Returns an array of this attachment object's headers, with one header
+per array entry. multiple lines are folded
+
+=begin testing
+
+my $test1 = "From: jesse";
+my @headers = RT::Attachment->_SplitHeaders($test1);
+is ($#headers, 0, $test1 );
+
+my $test2 = qq{From: jesse
+To: bobby
+Subject: foo
+};
+
+ at headers = RT::Attachment->_SplitHeaders($test2);
+is ($#headers, 2, "testing a bunch of singline multiple headers" );
+
+
+my $test3 = qq{From: jesse
+To: bobby,
+ Suzie,
+ Sally,
+ Joey: bizzy,
+Subject: foo
+};
+
+ at headers = RT::Attachment->_SplitHeaders($test3);
+is ($#headers, 2, "testing a bunch of singline multiple headers" );
+
+
+=end testing
+
+=cut
+
+sub _SplitHeaders {
+ my $self = shift;
+ my $headers = (shift || $self->SUPER::Headers());
+ my @headers;
+ for (split(/\n(?=\w|\z)/,$headers)) {
+ push @headers, $_;
+
+ }
+ return(@headers);
+}
+
+
sub ContentLength {
my $self = shift;
More information about the Rt-commit
mailing list