Inconsistent Attachments.Subject DB column content for non ASCII subjects

Hi,

in the attempt to fix [1] I just take a deeper look in which formats the
subject’s are saved in the DB (vanilla RT 4.2.9 and MySQL).
Actually they are UTF-8 or MIME encoded.
Is this behavior intentional or is this a bug?

Regarding 29714:
If you reply or comment on a ticket AND change the transaction subject,
the resulting attachment gets the subject set as UTF-8 and this subject
is shown in the ticket history, so far so good.
If you forward a ticket the resulting attachment gets the subject set as
MIME encoded string. As RT::Transaction->Subject doesn’t perform a MIME
decoding the subject for a forward transaction is shown as a MIME
encoded string which isn’t readable for the user (and maybe confuses
them if they don’t know anything about MIME encoding).
Should RT::Transaction->Subject expect an MIME encoded string and decode it?
Or should the content of the Attachments.Subject column always be
consistent UTF-8 (this would result in a huge upgrade step)?

Also, for create, reply and comment EmailRecord attachments (in the
example id’s 42, 51 and 56) the SubjectTag is added BEFORE the subject
is MIME encoded.
For Forward EmailRecord attachments (in the example id 70) the
SubjectTag is added AFTER the subject is MIME encoded, which I think is
wrong as the SubjectTag could contain non ASCII characters.

Chris

[1] Login

rt-attachment-subjects.txt (2.02 KB)