A solution for decoding iso-8859-1 subjects

I live in denmark and so once in a while use certain european characters
in the subjectlines. As RT does not decode this, I have been annoyed of
seeing something like:

in the queue-view. I have now made a little hack, which someone perhaps
could find usefull too. Is is not pretty nor perfect, but it works for me
:slight_smile:

The trick is to use the MIME-module in perl to decode the quoted-printable
characters and then substitute the ‘iso-8859-1’-tag away. This can, as I
said, probably be done quite more elegant, but hey, it works for me.

In lib/rt/ui/web/manipulate.pm, sub display_queue I changed
the place where ‘subject’ is printed to:

";
#By Jesper Holm Olsen: This decodes Quoted-printable from subject.
use MIME::QuotedPrint;
my $decoded;
$decoded = decode_qp($rt::req[$temp]{‘subject’});
$decoded =~ s/=?iso-8859-1?Q?(.*)?=/$1/;
print “$decoded ”;

This way at least my overview of a queue is pretty to read.

Jesper Holm Olsen, Department of Computer Science and Department of
Film and Media studies, University of Copenhagen
Email: dunkel@diku.dk * Homepage: http://www.diku.dk/students/dunkel

The trick is to use the MIME-module in perl to decode the quoted-printable
characters and then substitute the ‘iso-8859-1’-tag away. This can, as I
said, probably be done quite more elegant, but hey, it works for me.

In lib/rt/ui/web/manipulate.pm, sub display_queue I changed
the place where ‘subject’ is printed to:

Wouldn’t it be better to put the hack in mail/manipulate.pm?

Tobias Brox
aka TobiX
+47 22 925 871

The trick is to use the MIME-module in perl to decode the quoted-printable
characters and then substitute the ‘iso-8859-1’-tag away. This can, as I
said, probably be done quite more elegant, but hey, it works for me.

In lib/rt/ui/web/manipulate.pm, sub display_queue I changed
the place where ‘subject’ is printed to:

Wouldn’t it be better to put the hack in mail/manipulate.pm?

I thought about this too, but I think this is a “clean” way to do it as:

  1. It must be up to a users mailclient to decode the quoted-printable.
  2. If you make a reply, you’d have to encode it once again (this would’nt
    be to hard though, just use MIME::encode_qp.)

Also I have not tested if MySQL supports european characters.

Jesper Holm Olsen, Department of Computer Science and Department of
Film and Media studies, University of Copenhagen
Email: dunkel@diku.dk * Homepage: http://www.diku.dk/students/dunkel

Wouldn’t it be better to put the hack in mail/manipulate.pm?

I thought about this too, but I think this is a “clean” way to do it as:

  1. It must be up to a users mailclient to decode the quoted-printable.

Ok, that’s a point. Anyway, isn’t it also a problem that RT won’t
identify the “[MyTag #3432]” string when the subject is encoded?

  1. If you make a reply, you’d have to encode it once again (this would’nt
    be to hard though, just use MIME::encode_qp.)

I’d say there is no use for it. Ok, according to the RFC the subject
should only contain 7-bit characters, but in practice there is never any
problems for it - at least not when sticking to only one character set
(typically ISO-8859-1 for Denmark).

Also I have not tested if MySQL supports european characters.

No problems storing 8 bit characters in MySQL. I’m not sure if it has any
logic for separating different character sets … I guess it uses Locale
to decide how to handle case insensitive searches.

Tobias Brox
aka TobiX
+47 22 925 871

Wouldn’t it be better to put the hack in mail/manipulate.pm?

I thought about this too, but I think this is a “clean” way to do it as:

  1. It must be up to a users mailclient to decode the quoted-printable.

Ok, that’s a point. Anyway, isn’t it also a problem that RT won’t
identify the “[MyTag #3432]” string when the subject is encoded?

You actually have a very good point there. Therefor I spend some time
doing what you suggested and now I simply strip the encoding in
lib/rt/ui/manipulate/manipulate.pm in ‘sub parse_headers’:

sub parse_headers {
my ($content) =“@_”;

 ($headers, $body) = split (/\n\n/, $content, 2);

foreach $line (split (/\n/,$headers)) {
  
#By Jesper Holm Olsen (dunkel@diku.dk) 05/05/2000
#This decodes Quoted-printable from subject.
use MIME::QuotedPrint;
my $decoded;
$decoded = decode_qp($line);
$decoded =~ s/=\?iso-8859-1\?Q\?(.*)\?=/$1/;
$decoded =~ s/_/\ /g;
$line = $decoded;

I added a substituion for ‘'. This has the side-effect of removing
any '
’ in the original subject, but I can live with that. I have not read
the appropriate RFC or found a perl-module which could strip the encoding,
so now I just use this hack.

This works fine so far and the replies now gets stored in the right
ticket.

  1. If you make a reply, you’d have to encode it once again (this would’nt
    be to hard though, just use MIME::encode_qp.)

I’d say there is no use for it. Ok, according to the RFC the subject
should only contain 7-bit characters, but in practice there is never any
problems for it - at least not when sticking to only one character set
(typically ISO-8859-1 for Denmark).

Also a good point :slight_smile:

Also I have not tested if MySQL supports european characters.

No problems storing 8 bit characters in MySQL. I’m not sure if it has any
logic for separating different character sets … I guess it uses Locale
to decide how to handle case insensitive searches.

Well, it seems to work fine - for me anyway :slight_smile:

Jesper Holm Olsen, Department of Computer Science and Department of
Film and Media studies, University of Copenhagen
Email: dunkel@diku.dk * Homepage: http://www.diku.dk/students/dunkel