I think there’s something wrong here. First of all, I doubt the real reply had subject:
Subject: Re: [IT Podrška #13] AutoReply: Troubleshooting emails with knation
I would expect it to be encoded per RFC 2047:
Subject: Re: [IT =?UTF-8?Q?Podr=c5=a1ka?= #13] AutoReply: Troubleshooting emails with knation
Maybe the client is sending rfc6532 messages, but I find more likely that whatever was showing you the headers, automatically converted it.
Next, you would need to extract that from the header. I think that should be done in ExtractTicketId, probably at the $entity->head->get call. I have seen fully b64 subjects processed properly, so it is done.
sub ExtractTicketId {
my $entity = shift;
my $subject = Encode::decode( "UTF-8", $entity->head->get('Subject') || '' );
chomp $subject;
return ParseTicketId( $subject, $entity );
}
You can print it, if you want.
Now, you want this to match. You may think you are doing:
"[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/i
However, what you are doing is actually more like:
Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/iU
which won’t work
(test with perl -e 'use strict; use warnings; use Encode; print Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/i ? "yes\n" : "no\n";
)
You actually want to end up with a command like:
perl -e 'use strict; use warnings; use Encode; my $test = Encode::decode("UTF-8", "\QIT Podrška"); print Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[$test\E\s+\#/i ? "yes\n" : "no\n";'
The good news is that you don’t need to overlay ParseTicketId, you can achieve this simply by setting EmailSubjectTagRegex properly (btw, I would additionally accept both “IT Podrška” and “IT Podrska”).