unable to create IMAP folders containing & (ampersand)
Categories
(MailNews Core :: Networking: IMAP, defect)
Tracking
(thunderbird_esr78 unaffected, thunderbird89+ fixed)
| Tracking | Status | |
|---|---|---|
| thunderbird_esr78 | --- | unaffected |
| thunderbird89 | + | fixed |
People
(Reporter: phoenixuk06, Assigned: gds)
References
(Blocks 1 open bug)
Details
(Keywords: regression)
Attachments
(1 file, 5 obsolete files)
|
5.03 KB,
patch
|
benc
:
review+
wsmwk
:
approval-comm-beta+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0
Steps to reproduce:
File -> New -> Folder
or
right click account -> New Folder
enter name containing &, click Create Folder
folders created via webmail are visible
Application Basics
Name: Thunderbird
Version: 89.0a1
Build ID: 20210416094903
Distribution ID:
Update Channel: nightly
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Thunderbird/89.0a1
OS: Windows_NT 10.0 19042
Launcher Process: Enabled
Multiprocess Windows: 0/0
Fission Windows: 0/0
Disabled by safe mode
Remote Processes: 1
Enterprise Policies: Inactive
Google Location Service Key: Missing
Google Safebrowsing Key: Missing
Mozilla Location Service Key: Missing
Safe Mode: true
Actual results:
folder is not created (verified with webmail)
Expected results:
folder is created
Comment 1•4 years ago
|
||
I can confirm that there is something wrong with the MUTF-7 / UTF-8 handling.
I created a folder with the name "test&more" once with TB78.9.1 and once with current trunk build:
| created with: | TB78 | TB89 |
|---|---|---|
| file in Profile: | test&-more.msf | test&-more.msf |
| folder properties location: | test%26-more | test%26more |
| folder properties name: | test&more | test骊 |
| foldername in folderpane: | test&more | test骊 |
| foldername created on IMAP server: | test&-more | test&more |
Possibly a regression by Bug 1571672 or one of its regression fixes?
| Assignee | ||
Comment 3•4 years ago
|
||
I found the problem when the server is not UTF8=ACCEPT capable. In that case, as the reporter has observed, the server doesn't create the folder with "&" in it. On imap CREATE, the server reports that the mailbox name is not encoded with valid MUTF7.
The problem is because on folder create the string containing "&" is seen as ASCII so it is never converted to MUTF7. The attached diff fixes that.
However, there is still a problem with servers that do support UTF8=ACCEPT. For them the correct string is sent to create the folder and the server LISTs the correct folder string containing the "&". Also the profile folder name is correct and contain the "&" but the displayed folder name in the tree contains 3-byte UTF8 (e.g., "test&such" display as "test닧". Don't know where that is coming from.
| Assignee | ||
Comment 4•4 years ago
•
|
||
This adds a fix for the 2nd problem to the diff:
However, there is still a problem with servers that do support UTF8=ACCEPT. For them the correct string is sent to create the folder and the server LISTs the correct folder string containing the
&. Also the profile folder name is correct and contains the&but the displayed folder name in the tree contains 3-byte UTF8 (e.g.,test&suchdisplay astest닧. Don't know where that is coming from.
The problem here is that for UTF8=ACCEPT servers the folder name may be plain ASCII but contains a ampersand without a following dash as is required for MUTF-7. This causes bad conversion to UTF-16 which is used to display the folder name in the tree resulting in unexpected UTF-8 char(s) appearing such astest닧.
The solution is to check that the source string is valid MUTF-7. I can't find something like Is_MUTF7(str) so I convert it to UTF16 and then back to MUTF7. If if converts back to the same string then I assume that the source string is valid MUTF-7 and the conversion to UTF-16 is correct. Otherwise, I treat the ASCII string as UTF-8 and convert it to UTF-16.
This a hack on a "hacky function" so probably not optimal, but it seems to fix this bug. Also, left in some printfs I used to check that this really works.
Note: To create a folder named this test&-less you must enter test&--less; otherwise the dash does not appear and you get test&less for the folder name.
Comment 5•4 years ago
|
||
Sounds reasonable.
Currently, unfortunately, I can not compile myself. If you want me to test the patch before checkin, you would have to initiate a Windows try build.
Otherwise, give it a try.
| Assignee | ||
Comment 6•4 years ago
|
||
I also noticed that I needed the same fix for "rename" so this new diff includes it.
I did a "try" win64 build here as you requested:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=0448a9fb117193cd269a0472eff131a85f51b904
It works OK for me but good to have someone else try it.
The v3 diff is applied to the current trunk to produce the build.
Comment 7•4 years ago
|
||
(In reply to gene smith from comment #6)
Created attachment 9216936 [details] [diff] [review]
fix-lack-of-copy-to-mutf7-v3.diff
Works fine with my local non UTF8=ACCEPT IMAP server.
| Assignee | ||
Comment 8•4 years ago
|
||
Same as v3 diff but with printf's removed and clang format applied.
Updated•4 years ago
|
Comment 9•4 years ago
|
||
| Assignee | ||
Comment 10•4 years ago
•
|
||
Fixed the conditionals by adding braces.
Comment 11•4 years ago
|
||
Comment 12•4 years ago
|
||
Or shorter for the second choice: if (NS_SUCEEDED(CopyMUTF7toUTF16(aSrc, aDest))) {
| Assignee | ||
Comment 13•4 years ago
|
||
Updated per "Jose's" drive-by suggestion. I'll let Ben decide which version to go with or if it needs further tweaks.
Comment 14•4 years ago
|
||
Updated•4 years ago
|
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Comment 15•4 years ago
|
||
Note that TB 78 is not affected. The Unicode stuff started in bug 1571672 (TB 83). You should backport to beta though.
Updated•4 years ago
|
Comment 16•4 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/6e975cb9f460
Fix regression to allow creation and rename of imap folders containing ascii ampersand. r=benc
Comment 17•4 years ago
|
||
This is a regression and should go into beta.
Comment 18•4 years ago
|
||
Comment on attachment 9217528 [details] [diff] [review]
Bug1705765-proposed-fix-v3.patch
[Approval Request Comment]
Regression caused by (bug #): unclear exactly which, some of the IMAP UTF-8 bugs
User impact if declined: problems with folders containing &
Testing completed (on c-c, etc.): on c-c
Risk to taking this patch (and alternatives if risky): some, but not huge risk
Comment 19•4 years ago
|
||
Comment on attachment 9217528 [details] [diff] [review]
Bug1705765-proposed-fix-v3.patch
[Triage Comment]
Approved for beta
Comment 20•4 years ago
|
||
| bugherder uplift | ||
Thunderbird 89.0b3:
https://hg.mozilla.org/releases/comm-beta/rev/28f7dd70c681
Description
•