Closed Bug 1516320 Opened 7 years ago Closed 7 years ago

Quick search cannot find mails with quoted-printable + "ISO-2022-JP" body, finds raw text, like =1B$BF|K instead

Categories

(Thunderbird :: Search, defect)

defect
Not set
normal

Tracking

(thunderbird_esr6065+ fixed, thunderbird65 fixed, thunderbird66 fixed)

RESOLVED FIXED
Thunderbird 66.0
Tracking Status
thunderbird_esr60 65+ fixed
thunderbird65 --- fixed
thunderbird66 --- fixed

People

(Reporter: yuki, Assigned: jorgk-bmo)

Details

Attachments

(5 files, 3 obsolete files)

Bug 1427645 says that Quoted-Printable body is now supported for quick search. However, Tb doesn't list QT + ISO-2022-JP mails in the search result. Steps to reproduce: 1. Setup the local folder account. 2. Drag the downloaded "ISO-2022-JP+Quoted Printable.eml" to the inbox of the local folder account. 3. Activate "Quick Filter". 4. Input "日本語" into the text field. 5. Press the "Body" button. Actual result: * The imported mail is not listed in the search result. Expected result: * The imported mail is listed in the search result. Environment: * Daily 66.0a1 (2018-12-23) (64-bit) on Ubuntu 16.04LTS
Another testcase with QT + UTF-8. Tb lists this in the search result as expected.
One more testcase with QT + Shift_JIS. Tb lists this in the search result as expected.
Attachment #9033222 - Attachment mime type: application/x-extension-eml → text/plain
Attachment #9033223 - Attachment mime type: application/x-extension-eml → text/plain
Attachment #9033224 - Attachment mime type: application/x-extension-eml → text/plain
ISO-2022-JP is a 7bit encoding, so it doesn't really make much sense to use CTE QP for it. Does the body search work when it's 7bit encoded? Also, your sample message appears to have an encoding error since it's displayed as: 日本語の本文がQuoted Printableになっているもの�� I'll look into it after Christmas.
OK, there was a state switch to ASCII missing at the end: =1B$BF|K\8l$NK\J8$,=1B(BQuoted Printable=1B$B$K$J$C$F$$$k$b$N should be =1B$BF|K\8l$NK\J8$,=1B(BQuoted Printable=1B$B$K$J$C$F$$$k$b$N=1B(B If I turn the =1B back into ESC, marked as [ESC] (since BMO might strip the ESC character) [ESC]$BF|K\8l$NK\J8$,[ESC](BQuoted Printable[ESC]$B$K$J$C$F$$$k$b$N[ESC](B the body search actually works. So it's just the somewhat illegal QP encoding. I forgot to quote the spec in my previous comment, here it is: https://tools.ietf.org/html/rfc1468. Who creates those messages?
=1B$BF|K is actually found in the message :-(
Summary: Quick search cannot find mails with quoted-printable + "ISO-2022-JP" body → Quick search cannot find mails with quoted-printable + "ISO-2022-JP" body, finds raw text, like =1B$BF|K instead
The bug is clearly here: https://searchfox.org/comm-central/rev/4c3db8aa97f726068fe1021234575b2edb445af2/mailnews/base/search/src/nsMsgSearchTerm.cpp#953 where we spin some extra processing for "stateful" charsets, well, the only one left is ISO-2022-JP. Looking at the comments the original authors already knew that they're coding a problem :-(
This documents that currently 日本 is not found, but instead =1B$BF|K Unit test: mach xpcshell-test comm/mailnews/base/test/unit/test_searchBody.js I'll fix this with the next patch.
Assignee: nobody → jorgk
Status: NEW → ASSIGNED
Hmm, the code that breaks the QP search was added in bug 314637 but they never added a test :-( - So here we have one.
Attachment #9033345 - Attachment is obsolete: true
Here we go, all tests still pass, but now with the correct result. First reviewer will win. Nice exercise for Boxing Day ;-) - I fail to understand why bug 314637 added to the mess instead of implementing the dead-simple fix I have here. Yes, body search doesn't have a MIME parser, but it already does sufficient parsing that is can pick up the CTE which it's looking at headers anyway.
Attachment #9033350 - Flags: review?(mkmelin+mozilla)
Attachment #9033350 - Flags: review?(geoff)
Attachment #9033350 - Flags: review?(acelists)
Comment on attachment 9033350 [details] [diff] [review] 1516320-qp-iso-2022-jp.patch (v1) If this is winning I'd hate to not be winning…
Attachment #9033350 - Flags: review?(mkmelin+mozilla)
Attachment #9033350 - Flags: review?(geoff)
Attachment #9033350 - Flags: review?(acelists)
Attachment #9033350 - Flags: review+
Pushed by mozilla@jorgk.com: https://hg.mozilla.org/comm-central/rev/9211c27bcce1 Fix body search for QP-encoded messages using ISO-2022-JP. r=darktrojan
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Attachment #9033348 - Attachment is obsolete: true
Comment on attachment 9033350 [details] [diff] [review] 1516320-qp-iso-2022-jp.patch (v1) It was about time this got fixed properly.
Attachment #9033350 - Flags: approval-comm-esr60+
Attachment #9033350 - Flags: approval-comm-beta+
Target Milestone: --- → Thunderbird 66.0
Comment on attachment 9033350 [details] [diff] [review] 1516320-qp-iso-2022-jp.patch (v1) Review of attachment 9033350 [details] [diff] [review]: ----------------------------------------------------------------- This looks right conceptually. If we can see the encoding header then we should use it, why (wrongly) guess everything is QP. ::: mailnews/base/search/src/nsMsgBodyHandler.cpp @@ +389,5 @@ > nsCString lowerCaseLine(line); > ToLowerCase(lowerCaseLine); > > + if (StringBeginsWith(lowerCaseLine, NS_LITERAL_CSTRING("content-transfer-encoding:"))) > + m_partIsQP = lowerCaseLine.Find("quoted-printable", /* ignoreCase = */ true) != -1; kNotFound instead of -1?
Attachment #9033350 - Flags: review+
(In reply to :aceman from comment #14) > kNotFound instead of -1? Yes, but just below we have: if (lowerCaseLine.Find("text/html", /* ignoreCase = */ true) != -1) else if (lowerCaseLine.Find("multipart/", /* ignoreCase = */ true) != -1) and five more, so I wanted to go with the flow. No one noticed the missing initialisation, I'll attach another patch in a moment.
OK, I was so happy with the first patch that I forgot about the initialisation. In fact, it's not needed, since each message or part should provide a header that will set the variable. But for good house-keeping I've added it here.
Attachment #9033371 - Flags: review?(geoff)
Attached file ISO-2022-JP+Base64.eml (obsolete) —
What about 'CTE: base64'? This is still not found.
(In reply to Alfred Peters from comment #17) > What about 'CTE: base64'? This is still not found. Excuse me? What exactly isn't found? All should be (and is) found in base64 since I fixed bug 1259534. I searched for 日本 and it was found. That's already working in TB 60. If not, please file another bug, here we're doing QP.
(In reply to Jorg K (GMT+1) (urgent reviews and bustage fix only, Dec 22nd to Jan 1st) from comment #18) > (In reply to Alfred Peters from comment #17) > > What about 'CTE: base64'? This is still not found. > Excuse me? What exactly isn't found? All should be (and is) found in base64 > since I fixed bug 1259534. I searched for 日本 and it was found. That's > already working in TB 60. So you tried the search for 日本 with attachment 9033372 [details]? With me the mail is not found. UTF-8 mails are found. > If not, please file another bug, here we're doing > QP. I'll do
(In reply to Alfred Peters from comment #19) > So you tried the search for 日本 with attachment 9033372 [details]? > With me the mail is not found. UTF-8 mails are found. Yep. In TB 60.4. There shouldn't be a difference between UTF-8 and ISO-2022-JP after the base64 part is decoded.
(In reply to Alfred Peters from comment #19) > So you tried the search for 日本 with attachment 9033372 [details]? > With me the mail is not found. UTF-8 mails are found. After I repaired the folder that mail is now found. Really curious. Sorry for the noise - Case closed. O:-)
Comment on attachment 9033372 [details] ISO-2022-JP+Base64.eml Well, it goes through the folder line by line. If the MSF isn't right, then it won't work :-(
Attachment #9033372 - Attachment is obsolete: true
Attachment #9033371 - Flags: review?(geoff) → review+
Pushed by mozilla@jorgk.com: https://hg.mozilla.org/comm-central/rev/b3f44f8462f9 Follow-up: Initialise IsQP member variable where appropriate. r=darktrojan DONTBUILD
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: