HylaFAX The world's
most advanced open source fax server
|
|
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
Re: [hylafax-users] Charset conversion error in mail->faxmail->pdf&fax chain when using accents
I wrote a python script handling accents by substituting them with quotes and backquotes (don't ask me why, but faxmail gets mad when using backquotes in the subject field, while quotes give other kind of problems in the payload... who knows!
In case I'll have some spare time, I'll try working on the C code of faxmail itself. Also because I tried passing quoted printable chars in faxmail utf-ed, but it doesn't handle them, as Lee noticed.
Notice that this script acts like a filter, so you use it by means of its std IO. You can call it in a script that is in Postfix conf file
master.cf, in a line that pretty much goes:
cat | /usr/bin/RFC2047decoder.py > /usr/local/bin/faxmail -t done -s a4 -d $RECIPIENT $SEN
DER
Here's RFC2047decoder.py
:
#!/usr/bin/python
#RFC2047decoder.py
#v1.0
#Marcello Golfieri
import email
import sys
import quopri
Email=email.message_from_string(sys.stdin.read())
payload=Email.get_payload
()
subject=Email.get("Subject").strip()
accents={'à':"a'",'è':"e'",'é':"e'",'ì':"i'",'ò':"o'",'ù':"u'"}
accentspayload={'à':"a`",'è':"e`",'é':"e`",'ì':"i`",'ò':"o`",'ù':"u`"}
if subject.startswith('=?utf-8?'):
subj=quopri.decodestring(subject[10:-2])
for i in accents:
subj=subj.replace(i,accents[i])
Email.replace_header("Subject",subj.replace("_"," "))
payload=quopri.decodestring(payload)
for i in accents:
payload=payload.replace(i,accentspayload[i])
Email.set_payload(payload)
sys.stdout.write(Email.as_string())
On 6/23/07, Lee Howard
<faxguy@xxxxxxxxxxxxxxxx> wrote:
Marcello Golfieri wrote:
> Hi folks,
>
> I've got a problem with pdf notifications and accents. Italian
> language often uses accents such as in è é à ò ù ì. Problem is that
> in case you send through the chain mail->mta->faxmail binary any fax,
> using accented letters either in body and/or subject of the email that
> will go constitute the coverfax, you'll get weird characters back in
> attachment with your receipt, as well as on the receiving machines. I
> believe this is due to bad conversion between character set. Using
> "recode" I should fix the problem. I am trying to find the correct
> combination between input and output character set, but I am trying in
> complete blindness, taking up LOTS of time.
>
> I was wondering whether some of you out there already fixed this
> matter, and how. Or, in case you are using recode too, which
> parameters you pass to the binary to have a succesful conversion.
>
> if I insert any accented letters into the subject field I get
> something like :
>
> Subject: =?utf-8?Q?=C3=A8=C3=B2=C3=A0__prova?=
>
> both on the fax machine and in the notification pdf.
>
>
> In case I use accented letters into the body section, I get:
>
> =C3=B2=C3=A0=C3=A8 prova
>
> That would save me MANY hours of testing....
> But in case nobody knows a ready solution, I'll undergo this effort
> and post the solution once I'll find it. Hope not!
This problem has come up many times with non-english-speaking users.
Faxmail doesn't know how to deal with RFC2047-encoded Subject lines...
and I'm almost certain that it doesn't take the appropriate character
set into account when converting the message body into Postscript.
These are things that will need to have coding work done in faxmail to fix.
Thanks,
Lee.
--
Marcello Golfieri