[Rt-commit] rt branch, 4.0/repeated-subject-header, created. rt-4.0.2-112-g88b7e82
Alex Vandiver
alexmv at bestpractical.com
Tue Sep 20 13:22:13 EDT 2011
The branch, 4.0/repeated-subject-header has been created
at 88b7e82cbc67072a2325b520ba7bd6772849ea37 (commit)
- Log -----------------------------------------------------------------
commit 88b7e82cbc67072a2325b520ba7bd6772849ea37
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Sep 20 13:13:54 2011 -0400
Preserve header values which start with their own header names
Mail::Header (the parent class of MIME::Header) has the following
helpful property:
$ perl -MMail::Header -e '$h = Mail::Header->new;
$h->add("Subject", "Subjec: moose");
print $h->as_string'
Subject: Subjec: moose
$ perl -MMail::Header -e '$h = Mail::Header->new;
$h->add("Subject", "Subject: moose");
print $h->as_string'
Subject: moose
To preserve the header precisely as we had it previously, prepend the
value with a space when we re-add it. This space is stripped before the
header is stored, but suffices to prevent the matching prefix from being
removed.
diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index b9c1c54..db10584 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -541,7 +541,13 @@ sub SetMIMEHeadToEncoding {
}
$value = DecodeMIMEWordsToEncoding( $value, $enc, $tag )
unless $preserve_words;
- $head->add( $tag, $value );
+
+ # We intentionally add a leading space when re-adding the
+ # header; Mail::Header strips it before storing, but it
+ # serves to prevent it from "helpfully" canonicalizing
+ # $head->add("Subject", "Subject: foo") into the same as
+ # $head->add("Subject", "foo");
+ $head->add( $tag, " " . $value );
}
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list