HTML ja signature displays as garbage in the mail body

VERIFIED FIXED in mozilla0.9.4


MailNews Core
18 years ago
7 years ago


(Reporter: ji, Assigned: (away - not reading bugmail))



Windows 95

Firefox Tracking Flags

(Not tracked)


(Whiteboard: fixed on the trunk (0.9.4))


(9 attachments)



18 years ago
******observed with 2000101208 branch build****

Attach a Japanese HTML signature file to a HTML mail. After received, the 
Japanese signature is displayed garbled in the mail body.

Steps to reproduce:
1. Launch mail.
2. Set mail compose style to HTML format.
3. Set mail preference to attach a Japanese HTML file in ShiftJis when you 
compose a mail.
4. Compose a mail attached with a Ja HTML signature file.
   In the mail compose window, the Japanese signature is displayed alright.
5. Send the mail to your testing account itself after setting the encoding to 
6. After you receive the mail, you'll see the Japanese signature is garbled.

Only HTML mail with Japanese HTML signature combination will have this problem.

Comment 1

18 years ago
Created attachment 16909 [details]
Attached a mail folder containing the problematic mail.

Comment 2

18 years ago
This is a cross-platfrom problem.
Hardware: PC → All

Comment 3

18 years ago
This is caused by inconsistent charset labels (the signiture part and META of
the signature HTML). The message can be seen if I edit the mail source and
remove the META tag.
We could try to fix this in two ways.
* When attaching a signature, parse and remove the META tag.
* Do not convert a signature HTML file to mail charset (e.g. ISO-2022-JP) and
not put a charset label for the signature part.

Content-Type: text/html; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit

<div class="moz-signature">-- <br><title>moz-sign</title>




18 years ago
Target Milestone: --- → M23


18 years ago
Keywords: intl

Comment 4

18 years ago
Mass change of QA contact to ji for the bugs filed by her.
QA Contact: momoi → ji


18 years ago
Target Milestone: --- → Future

Comment 5

18 years ago
*** Bug 76362 has been marked as a duplicate of this bug. ***

Comment 6

18 years ago
NHotta/Jenm - please re-eval for nsbeta1.
Keywords: nsbeta1

Comment 7

17 years ago
NHotta/Jenm - please re-eval for M0.9.2 or agree to Furture milestone.

Comment 8

17 years ago
The possbile fixes I mentioned before:
* When attaching a signature, parse and remove the META tag.
* Do not convert a signature HTML file to mail charset (e.g. ISO-2022-JP) and
not put a charset label for the signature part.

The first one is not a small change. I can investigate the second option.
I would like to know how often this is used, I mean HTML signature which is
created by HTML editor.

Comment 9

17 years ago
*** Bug 86784 has been marked as a duplicate of this bug. ***


17 years ago
Target Milestone: Future → ---


17 years ago
Keywords: nsBranch
this is on Cindy's list for eMojo, cc'ing myself and ftang

Comment 11

17 years ago
mark it as moz0.9.4 and P2. reassign to jbetak. jbetak- think about how to fix 
this one.
Assignee: nhotta → jbetak
Priority: P3 → P2
Target Milestone: --- → mozilla0.9.4


17 years ago
Whiteboard: nsBranch+
I'll be working on this over the weekend... Hope to have a fix by 08/21 - 
before the a= period begins.
it really looks like the trouble begins when reading the signature file. We are 
implicitly assuming it is in the platform encoding when converting it to the 
internal UCS-2 representation. This means that on a US Windows installation we 
will handle a say Shift_JIS signature file as if it was encoded in win1252.

Second part of the problem is sending the signature from the mail client. Since 
we will need to determine the file encoding when reading it from disk, we could 
use that charset information as a hint, label the sig file properly and send it 
out unmodified. Although, this does not cover mislabeled signatures, it should 
be enough for most real-life scenarios.
upon addressing bug 91670 I've noticed that emails sent from Mozilla per repro 
steps outlined in this bug in fact *do* render correctly in other mail clients 
(say Outlook or Webmail). I'll try to see, how I could tweak the display side 
of things in Mozilla to make the messages appear correctly...
Created attachment 46528 [details] [diff] [review]
cvs diff -u -b -w .\mailnews\compose
this patch contains the fix for bug 91670 as well. They both seem to be related 
and I'm quite happy with the approach outline in the patch. I believe it's the 
best and most logical modification and has the advantage to be very contained, 
which would make any backout in case of regressions very easy.

I'm beginning to believe that I should limit this fix to work on HTML 
signatures only, although determining the file type will add quite a bit of 
overhead - unless we cache it in an earlier step... I'll look into it tonight. 
Meanwhile the patch is fully functional and I'm very happy with the way things 
are shaping out.

cc'ing some mailnews folks for additional input / possible r/sr.
Whiteboard: nsBranch+ → nsBranch+, have patch - need r/sr
Looks good. R=ducarroz
cc'ing blizzard for potential i18n sr

make sure to test that signatures are still ok on US-ASCII machines.
fix checked in - thanks everyone!

ji - I'll write an email to marina regarding bug 91670, as this checkin
addresses that bug too. We should retest mail signatures (both ASCII and
non-ASCII) very carefully to make sure there will be no regressions for eMojo.
Last Resolved: 17 years ago
Resolution: --- → FIXED

Comment 22

17 years ago
With 08-22-08-trunk build, it seems bug 91670 is fixed. But the problem
described in this report is not completely gone. It only works when mail is sent
in plain text only format. If the mail is sent in HTML only or both in plain
text and HTML format with a html signature file, the mail is garbled after
received.  Reopened the bug.
Resolution: FIXED → ---

Comment 23

17 years ago
Created attachment 46740 [details]
A sjis html file that can be used as a signature file.
>If the mail is sent in HTML only or both in plain
>text and HTML format with a html signature file, the mail is garbled after

Xianglang, I'd like to talk to you about this - I certainly tested all mail 
formats in my debug build and from the nature of the fix it would be highly 
surprising to see it work for HTML only. If something is still broken, it will 
be most likely a little more specific and not affect all HTML-formatted mails.

Please provide more info - like what was your mail composition charset, what 
signature did you use, what was its charset, did it have a meta tag etc.
Keywords: nsBranch → nsbranch

Comment 25

17 years ago
The mail composition charset is ISO-2022-JP, the signature files I tested 
include euc-jp html file and Shift-JIS html file, and the signature files have 
charset meta tag. 
Again, it only works when the mail is sent in plain-text only format.
It doesn't work when the mail is sent in HTML only format or in plain text and 
HTML format. (there are three options to choose before sending out the mail, it 
only works when the 2nd one is chosen)

Comment 26

17 years ago
Xianglan, is the display broken while you compose or you see it when the mail is
I think I get it - it's still broken for messages composed in ISO-2022-JP with 
a Japanese signature file. I have a feeling I know why that is, but Xianglang 
just try to change your composition encoding to anything else except ISO-2022-
JP while keeping the the signature the same. I think it'll be not garbled.

Comment 28

17 years ago
When the mail is sent in utf8, it's not garbled, but the signature ( a sjis 
html file) is not displayed correctly. Screen shot to follow.

Comment 29

17 years ago
Created attachment 46793 [details]
A utf8 mail with the signature sjis file I attached to this report.
OK, I think I found the glitch in this fix:

We parse the charset from the signature file correctly, but it gets converted 
to all uppercase in the process! This means that we won't find it again, when 
trying to replace the charset encoding string in the meta tag, which can cause 
problems with the display since we are sending the sig file properly converted, 
but mislabeled.

Xianglang, could you please change the charset string in your test signature 
file to all uppercase and try again? I'll attach your test file modified in 
such a way also. If that succeeds, then we can be sure that it's just this 
silly omission...
Created attachment 46868 [details]
SHIFT_JIS signature file with the charset name in all uppercase
Created attachment 46870 [details] [diff] [review]
missed this change in the meta charset parser - it returns the real value of the existing charset, instead of uppercase

I missed this change in the patch. I didn't realize that the parser changes the 
charset into an all-uppercase value. I'd like to modify it, so that it returns 
the true value of the charset it found. It can be then more easily substituted -
 the string classes don't provide case-insensitive substring replacement yet.

Could you please have another look?

Comment 34

17 years ago
The signature file attached at 08/23/01 00:20 doesn't work. It seems that
changing the charset meta tag to upper case doesn't make differences.
looks good. R=ducarroz
thanks ducarroz!

sspitzer: could you please have another look as well? I missed this in my 
original patch. The parsed meta charset is currently converted to all uppercase 
by the i18n utility parser, which makes it hard to replace.

Comment 37

17 years ago
Seth's on vacation sr=bienvenu
thanks bienvenu!

asa, could you a=?
Whiteboard: nsBranch+, have patch - need r/sr → nsBranch+, have patch - need a=
Created attachment 47032 [details] [diff] [review]
looks like nhotta's original recommendation to remove the charset was right on the money, parsing the charset out during user override turns out to be very laborious and inefficient
Created attachment 47034 [details] [diff] [review]
cleaned-up patch to remove sig charset
ducarroz, bienvenu: could I pester you some more? 

Looks like keeping the signature charset in sync with the message charset takes 
up too much bandwidth. Local i18n QA pointed out that manual charset overrides 
are quite frequent during composition and as it turns out, it's takes quite a 
bit of effort to parse the signature charset from the message body. I think it 
would be inefficient to burden the product with this.

I'd like to stick with nhotta's original recommendation  to remove the meta 
charset from the signature, although I was originally hesitant, since it's a 
more intrusive approach.
Whiteboard: nsBranch+, have patch - need a= → nsBranch+, have patch - need sr/a=
bienvenu: are you reading this? Could you help me to get this into the tree 
before tomorrow's freeze?

cc'ing mscott as last resort mailnews sr, since sspitzer is apparently on 

would you be able to sr this? This bug is one of i18n's top priorities for 

Comment 45

17 years ago
Per Selmer suggestion, I am doing this myself.

Moving nsbranch+ designation from the Status Whiteboard to Keywords.

Jbetak - Pls send an email to drivers, if blizzard can help with sr/a by the end
of the day.
Keywords: nsbranch → nsbranch+
Whiteboard: nsBranch+, have patch - need sr/a= → have patch - need sr/a=

+    metaCharset.AssignWithConversion("charset=");

can't you do metaCharset = NS_LITERAL_STRING("charset=").get(); or something
that doesn't require a conversion?

+    metaCharset.Append(sigEncoding);
+    int metaCharsetOffset = sigData.Find(metaCharset,true,0,-1);

use a PRInt32 instead of int.
+    if (0 < metaCharsetOffset)

I'd prefer:

if (metaCharsetOffset != kNotFound)

since Find returns kNotFound (-1) on failure, right

can you address those nits, and attach a new patch?
Created attachment 47582 [details] [diff] [review]
Updated patch - addressed the issues raised by sspitzer

I've attempted to address the issues you raised, could you have another look?
looks good.  sr=sspitzer
Whiteboard: have patch - need sr/a= → have patch - need a=

Comment 50

17 years ago
a=asa on behalf of drivers.
OK, so the second installment of this fix just went in. Hope the QA will be 
more content with the results this time.

Thanks everyone for all your help!
Last Resolved: 17 years ago17 years ago
Resolution: --- → FIXED
Whiteboard: have patch - need a= → fixed on the trunk (0.9.4)

Comment 52

17 years ago
Verified with 09/04 builds. It's fixed.
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.