Closed
Bug 1358049
Opened 9 years ago
Closed 9 years ago
Font name were garbled in Compose window if Font name is non-acsii character
Categories
(Thunderbird :: Message Compose Window, defect)
Tracking
(thunderbird_esr45 wontfix, thunderbird_esr5254+ fixed, thunderbird54 fixed, thunderbird55 fixed)
RESOLVED
FIXED
Thunderbird 55.0
People
(Reporter: alice0775, Assigned: jorgk-bmo)
References
Details
(Keywords: intl, regression)
Attachments
(2 files)
|
35.25 KB,
image/png
|
Details | |
|
1.71 KB,
patch
|
aceman
:
review+
jorgk-bmo
:
approval-comm-beta+
jorgk-bmo
:
approval-comm-esr52+
|
Details | Diff | Splinter Review |
Steps To Reproduce:
1. I am not sure but it is require Localized Windows.
In my case, Windows10 Home 64 bit Japanese Edition
2. Start Thunderbird
(not regardless of en-US build or ja build)
3. Open Compose window with HTML mode
4. Click message body pane to focus it
5. Select a font name from dropdown list
In this case "MS ゴシック"
Actual Results:
Font name in the toolbar is garbled and indicated as not installed.
See attached screenshot.
Expected Results:
Font name in the toolbar should be "MS ゴシック"
| Reporter | ||
Comment 1•9 years ago
|
||
Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=139446daedab3d00b9f0faba25e1e82191c8c8d1&tochange=56f5ffd44b7f13d5db5bd497018f428dcbb28fc4
https://hg.mozilla.org/comm-central/pushloghtml?fromchange=929b56b8c1ad&tochange=b7472e239aa2
Suspect:
0b5b80bde5b9 aceman — Bug 1148790 - Add unknown fonts from message compose to the fonts menu. ui-r=bwinton, r=mkmelin, r=IanN
Blocks: 1148790
Flags: needinfo?(acelists)
| Assignee | ||
Comment 2•9 years ago
|
||
Sure, the "(not installed)" got added, but I don't see why that should make if garbled.
OK, can you determine if the garbled string is passed to us into the function onFontFaceChange in the file editor/ui/composer/content/editor.js ?
At the top of the function dump the value of editorFont whether the bad string is there:
function onFontFaceChange(fontFaceMenuList, commandID)
{
var commandNode = document.getElementById(commandID);
var editorFont = commandNode.getAttribute("state");
Flags: needinfo?(acelists)
| Assignee | ||
Comment 4•9 years ago
|
||
I guess Alice builds FF and TB, right? If not, you can unpack omni.ja and add one line in there. Let me know if that's unclear. Or use remote debugging?
What I don't understand is comment #0:
5. Select a font name from dropdown list
In this case "MS ゴシック"
So the drop down looks OK, I assume. It shows available fonts. So after it's applied, it shows "#$@#(garbled)##$% (not installed)". That's weird, but yes, "#$@#(garbled)##$%" is not installed, the installed font is "MS ゴシック".
Flags: needinfo?(alice0775)
| Reporter | ||
Comment 5•9 years ago
|
||
I add logStringMessage as follows:
function onFontFaceChange(fontFaceMenuList, commandID)
{
var commandNode = document.getElementById(commandID);
var editorFont = commandNode.getAttribute("state");
+ Components.classes["@mozilla.org/consoleservice;1"]
+ .getService(Components.interfaces.nsIConsoleService)
+ .logStringMessage("onFontFaceChange: " + editorFont);
// Strip quotes in font names. Experiments have shown that we only
// ever get double quotes around the font name, never single quotes,
// even if they were in the HTML source. Also single or double
When I select "MS ゴシック" once, Error console shows the following two results.
onFontFaceChange: MS ゴシック
onFontFaceChange: ï¼ï¼³ ã´ã·ãã¯
Flags: needinfo?(alice0775)
| Reporter | ||
Comment 6•9 years ago
|
||
FYI,
The problem seems to be fixed if I change the editor.js as following().
function onFontFaceChange(fontFaceMenuList, commandID)
{
var commandNode = document.getElementById(commandID);
var editorFont = commandNode.getAttribute("state");
// Strip quotes in font names. Experiments have shown that we only
// ever get double quotes around the font name, never single quotes,
// even if they were in the HTML source. Also single or double
// quotes within the font name are never returned.
editorFont = editorFont.replace(/"/g, "");
+ var UI = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].
+ createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ UI.charset = "UTF-8";
+ editorFont = UI.ConvertToUnicode(editorFont);
switch (editorFont) {
case "mixed":
// Selection is the "mixed" ( > 1 style) state.
| Assignee | ||
Comment 7•9 years ago
|
||
Thanks for the hint. nsIScriptableUnicodeConverter is deprecated, bug 1347877, but we can use something else.
So you choose the font from the menulist and get 2 message output, the second time the it is garbled.
OK, I can reproduce this on Linux using a crafted message containing <font face="MS ゴシック">...</font> .
I can also see some problem with a font having apostrophe (') in the name. Strangely, a font having name in Greek appears fine.
For some reason in ComposerCommands.js::pokeMultiStateUI() the font name goes through the desiredAttrib = cmdParams.getCStringValue("state_attribute"); path (notice CString)...
Doing the conversion to UTF-8 in this function also fixes it for me. This needs deeper analysis why this attribute is encoded as CString, not UTF-8 String already. I don't know yet which code sets these 'state' attributes and what the cmdParams are.
| Assignee | ||
Comment 10•9 years ago
|
||
Nice analysis so far.
I think the states are the states of the editor here, so in which font, size, bold, underline, paragraph style, etc. are we currently. Can you please try to remove the |if (valuetype == Components.interfaces.nsICommandParams.eStringType)| and always use |desiredAttrib = cmdParams.getStringValue("state_attribute");| and see what happens at
https://dxr.mozilla.org/comm-central/rev/c1f32169afa72cbb606cb135d978b29e131ec169/editor/ui/composer/content/ComposerCommands.js#368
Comment 11•9 years ago
|
||
Yes I tried that and it makes TB half-hanged. I'm not sure if it totally crashed, but as if no further JS gets executed and some windows couldn't be closed. In one case I had to kill it from the command line.
| Assignee | ||
Comment 12•9 years ago
|
||
Huh? Doesn't crash/hang for me but it throws and I get this in the catch:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsICommandParams.getStringValue]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://editor/content/ComposerCommands.js :: pokeMultiStateUI :: line 369" data: no]
I changed getCStringValue() to getStringValue() at line 369. So I think we leave the former and do the UTF-8 trick, right?
Comment 13•9 years ago
|
||
(In reply to Jorg K (GMT+2) from comment #12)
> I changed getCStringValue() to getStringValue() at line 369. So I think we
> leave the former and do the UTF-8 trick, right?
I don't know yet. What if also other attributes (not just font name) are passed via this path and are not just CString encoded UTF-8 strings? What if our added UTF-8 decoding them garbles those? We should see if this isn't a gecko bug or if it is intentional and if we do not have to adapt in some way.
Alice, what is the TB version you are trying it on? The "culprit" bug was landed in TB43. Are you seeing this on the official TB45 or is it a nightly build (55). I can see it on nightly.
| Reporter | ||
Comment 14•9 years ago
|
||
(In reply to :aceman from comment #13)
> Alice, what is the TB version you are trying it on?
45.8.0
> The "culprit" bug was landed in TB43.
> Are you seeing this on the official TB45 or is it a nightly
> build (55). I can see it on nightly.
Yes, I can reproduce on 45.8.0 and Daily55.0a1
| Assignee | ||
Comment 15•9 years ago
|
||
(In reply to :aceman from comment #13)
> I don't know yet. What if also other attributes (not just font name) are
> passed via this path and are not just CString encoded UTF-8 strings? What if
> our added UTF-8 decoding them garbles those? We should see if this isn't a
> gecko bug or if it is intentional and if we do not have to adapt in some way.
If you encode ASCII as UTF-8 you get the same result, so there is no harm done at all.
The Gecko bug might be that we need to use getCStringValue() and getStringValue() fails as per comment #12.
I'd add something like this |let encodedText = new TextEncoder("UTF-8").encode(text);|
https://dxr.mozilla.org/comm-central/rev/fcf3534bdd64fcf673c9a230a660468680da4de6/mailnews/mime/jsmime/jsmime.js#2904
after the getCStringValue(). I'll try it myself once my build finishes.
| Assignee | ||
Comment 16•9 years ago
|
||
This works. If ASCII is returned in the CString, the decode does nothing. If UTF-8 is returned, we decode it properly to a JS string, I believe UTF-16.
Tested with a message as per comment #8.
Code inspired by:
https://dxr.mozilla.org/comm-central/rev/5d39d63d0bf223541c5515ab2691736f5a638ded/mailnews/compose/test/unit/test_longLines.js#46
Comment 17•9 years ago
|
||
Alice's code was shorter. Is this awful code the replacement for nsIScriptableUnicodeConverter ?
| Assignee | ||
Comment 18•9 years ago
|
||
Awful code?? I feel insulted now ;-) The replacement depends on the case. If you read bug 1347877, changes are the we're moving this to C-C anyway.
| Assignee | ||
Comment 19•9 years ago
|
||
Grammar failed: If you read bug 1347877, chances are that we're moving this to C-C anyway.
| Reporter | ||
Comment 20•9 years ago
|
||
(In reply to :aceman from comment #17)
> Alice's code was shorter. Is this awful code the replacement for
> nsIScriptableUnicodeConverter ?
Code of comment#6 outputs several error in Error console when editorFont fails to convert to unicode.
Comment 21•9 years ago
|
||
No offence, you just dared to copy awful code :)
| Assignee | ||
Comment 22•9 years ago
|
||
No, I *wrote* test_longLines.js. It took me quite some time to understand all the intricacies and to put it all together.
Comment 23•9 years ago
|
||
Comment on attachment 8867839 [details] [diff] [review]
1358049-getCStringValue-decode-utf8.patch (v1).
Review of attachment 8867839 [details] [diff] [review]:
-----------------------------------------------------------------
This works to fix the bug, I just hope it doesn't break something else.
Attachment #8867839 -
Flags: review?(acelists) → review+
| Assignee | ||
Comment 24•9 years ago
|
||
https://hg.mozilla.org/comm-central/rev/249bb3317336f0856202b29fd6eb0f28f1a62030
(In reply to :aceman from comment #23)
If ASCII weren't a subset of UTF-8, then the world would come to a stand-still. So I don't see what could possibly break. But then, I've been wrong before ;-(
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-thunderbird51:
wontfix → ---
status-thunderbird52:
wontfix → ---
status-thunderbird53:
wontfix → ---
tracking-thunderbird_esr52:
--- → +
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 55.0
| Assignee | ||
Comment 25•9 years ago
|
||
Comment on attachment 8867839 [details] [diff] [review]
1358049-getCStringValue-decode-utf8.patch (v1).
Long-standing bug, let's get it fixed one day on the branches ;-)
Attachment #8867839 -
Flags: approval-comm-esr52?
Attachment #8867839 -
Flags: approval-comm-beta+
Comment 26•9 years ago
|
||
(In reply to Jorg K (GMT+2) from comment #24)
> If ASCII weren't a subset of UTF-8, then the world would come to a
> stand-still.
I don't think this is exact. Maybe the first 128 chars (7bit) are a subset (represent the same chars) of UTF-8. There must be some characters that indicate you need to read more (e.g. 2 bytes) to compose a letter. Thus that leading character no longer is the same meaning as in ASCII.
| Assignee | ||
Comment 27•9 years ago
|
||
Sure, 7bit ASCII is a subset of UTF-8. The "read more" bytes all have the high-bit set:
https://en.wikipedia.org/wiki/UTF-8#Description
Backward compatibility: One-byte codes are used for the ASCII values 0 through 127, so ASCII text is valid UTF-8.
| Assignee | ||
Comment 28•9 years ago
|
||
| Assignee | ||
Updated•9 years ago
|
Attachment #8867839 -
Flags: approval-comm-esr52? → approval-comm-esr52+
| Assignee | ||
Comment 29•9 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•