folderLookupService doesn't handle folder creation correctly if URI contains accent/diacritic (e.g. Envoyés).
Categories
(Thunderbird :: General, defect)
Tracking
(thunderbird_esr78 unaffected)
Tracking | Status | |
---|---|---|
thunderbird_esr78 | --- | unaffected |
People
(Reporter: benc, Assigned: benc)
References
Details
Attachments
(2 files, 1 obsolete file)
2.23 KB,
patch
|
Details | Diff | Splinter Review | |
23.89 KB,
patch
|
mkmelin
:
review+
|
Details | Diff | Splinter Review |
The initMoveToFolderAgainMenu()
function in mailWindowOverlay.js doesn't seem to handle diacritic/accent characters.
The upshot is that it creates a new folder (in memory) instead of finding the existing one!
To replicate:
- add printfs to dump out info in nsMsgDBFolder::Init() and nsMsgDBFolder::parseURI() - I'll upload a patch.
- create a gmail IMAP account in TB
- In that account, create a subfolder with an accent/diacritic, e.g. "testé" (location of the folder doesn't matter)
- move any old message into that folder
- Select the folder
- right click on the message to trigger initMoveToFolderAgainMenu().
- check through the output on stdio
So, when TB starts up, it picks up the folder just fine and the URI is correct:
XYZZY: 0x0x7fc306944000 (Init() uri='imap://username%40gmail.com@imap.gmail.com/testé' len=54 0x69 0x6d 0x61 0x70 0x3a 0x2f 0x2f 0x74...
XYZZY: parseURI 0x0x7fc306944000 escapedFileName='test%C3%A9' len=10 0x74 0x65 0x73 0x74 0x25 0x43 0x33 0x25
But, at step 6, it's invoked initMoveToFolderAgainMenu(), which calls MailUtils.getOrCreateFolder() with a badly-encoded URI:
XYZZY: 0x0x7fc305263c00 (Init() uri='imap://username%40gmail.com@imap.gmail.com/test' len=53 0x69 0x6d 0x61 0x70 0x3a 0x2f 0x2f 0x74...
XYZZY: parseURI 0x0x7fc305263c00 escapedFileName='test%E9' len=7 0x74 0x65 0x73 0x74 0x25 0x45 0x39
Because it's a different URI, it doesn't find the existing folder, and creates a new one in memory (ugh!).
As far as I can tell, the URI in "mail.last_msg_movecopy_target_uri" is coming out borked... (maybe it was borked when set...)
Assignee | ||
Comment 1•4 years ago
|
||
Actually, probably don't really need this patch - could just sprinkle dump() calls about on the JS side... but hey.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
I'm pretty sure it's because nsIMsgFolder.init(string uri)
takes a string. Works fine from C++ - the param is a const char *
and utf-8 passes through just fine. But calling it from javascript screws up the encoding.
I'm changing it to a AUTF8String
(and adding a unit test to exercise it). But tomorrow.
Assignee | ||
Comment 3•4 years ago
|
||
This changes the IDL definition of an important folder-creation step:
nsIMsgFolder.Init(in string uri)
to:
nsIMsgFolder.Init(in AUTF8String uri)
This means that URIs containing unicode characters passed in from javascript won't get all screwed up - they'll instead be converted to UTF-8.
It's not at all clear which places use percent-encoded (ie ASCII-safe) URIs, and which places use non-percent-encoded UTF-8 URIs, but at least nsIMsgFolder.Init() won't be responsible for screwing it up :-)
It also changes a bunch of related functions to take an abstract nsACstring
as a uri param rather than the overly-concrete nsCString
.
And yes, the idl Init()
signature should probably be lower-cased, but I think I'd rather like to try and get rid of it completely as part of the gradual folder-creation tidy-up.
Try run here,
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=7e42ec5c5dc4d433b8ab3801cbfd2c40f075e37e
Comment 4•4 years ago
|
||
Seems with 1687412-fix-up-string-types-1.patch, if I have a testé
folder, with every restart, a few new testé
folders are created.
Comment 5•4 years ago
|
||
Change to use AUTF8String
in nsIFolderLookupService.idl fixes comment 4 for me.
Comment 6•4 years ago
|
||
Comment 7•4 years ago
|
||
(In reply to Ping Chen (:rnons) from comment #5)
Change to use
AUTF8String
in nsIFolderLookupService.idl fixes comment 4 for me.
Too many patches in the air right now. Is this in one of them, or something still needed?
Comment 8•4 years ago
|
||
It's need(In reply to Magnus Melin [:mkmelin] from comment #7)
(In reply to Ping Chen (:rnons) from comment #5)
Change to use
AUTF8String
in nsIFolderLookupService.idl fixes comment 4 for me.Too many patches in the air right now. Is this in one of them, or something still needed?
It's needed in my testing, otherwise duplicated folders are created on every restart. I will test again, and upload a new patch here.
Comment 9•4 years ago
|
||
Ben's patch with two line changes in nsIFolderLookupService.idl
Updated•4 years ago
|
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/3410cfd4332d
Fix up string types in folder creation to better handle unicode URIs. r=mkmelin
Assignee | ||
Comment 11•4 years ago
|
||
(In reply to Ping Chen (:rnons) from comment #8)
It's needed in my testing, otherwise duplicated folders are created on every restart. I will test again, and upload a new patch here.
Doh! I totally missed that.
Thanks for testing it and patching it up!
Description
•