Closed Bug 113050 Opened 23 years ago Closed 23 years ago

'Forward as attachments' for multiple IMAP messages broken in 0.9.6 (worked in 0.9.5)

Categories

(MailNews Core :: Composition, defect, P2)

x86
All

Tracking

(Not tracked)

VERIFIED FIXED
mozilla1.0

People

(Reporter: russ, Assigned: bugzilla)

References

Details

(Keywords: regression, Whiteboard: Have fix, ready to go)

Attachments

(1 file, 7 obsolete files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.5) Gecko/20011011
BuildID:    v0.9.6 (using a different version at the mo so don't know build ID)

When I select several messages in my IMAP Inbox (or any other folder, I assume),
right-click then select 'Forward as attachments', only one attachment appears in
the box - it seems to be a hash-separated list of the messages.
When I attempt to send the message, I get an error from my mailserver to the
effect that it can't find the specified messages.
This feature worked fine in 0.9.5 but not in 0.9.6 - all the messages were
displayed as separate attachments and sent with no problem.

Reproducible: Always
Steps to Reproduce:
1. Select several messages in window
2. Right click
3. Select 'Forward as attachments'
4. Enter an e-mail address for recipient
5. Click 'Send'


Actual Results:  Error message from IMAP server (haven't tried POP3) that it
couldn't find message with that ID

Expected Results:  Found all selected messages, attached them to the mail, and
sent it.

Works fine when sending single message as attachment
confirming on commercial build: 2001-12-03-06
Forwarding multiple messages(more than one) attaches only the first message
selected. (Forwarding as attachment).  We could forward multiple messages as
attachments before and we should do that. Since we do not do it inline which is
a known bug.  
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: nsbeta1
OS: Windows 2000 → All
After I try to forward multiple messages as attachments, my Sent log shows not a
"hash-separated list of the messages" but only one of those attached emails. 
Judging by SpamCop.net's response to the forwarding, only one forwarded message
was received as well.  (Mozilla 0.9.6)
Tis is a regression caused by my checkin for bug 86089. in nsMsgCompose.cpp, in
the code:
          if (NS_SUCCEEDED(rv) && attachment)
          {
            attachment->SetName(decodedSubject.get());
            attachment->SetUrl(originalMsgURI);
            m_compFields->AddAttachment(attachment);
          }

originalMsgURI contains a comma separated list of url that need to be split a
part! Also, we need to query the subject of each messages and not reuse the
first one.
Status: NEW → ASSIGNED
Keywords: regression
Target Milestone: --- → mozilla0.9.9
Keywords: nsbeta1nsbeta1+
Priority: -- → P2
Attached patch patch, v1 (obsolete) — Splinter Review
I'm not quite sure about use of GetTopmostMsgWindowCharacterSet and charset
override logic. Except this, multiple message forwarding seems to work...
Attached patch (somewhat) better patch, v2 (obsolete) — Splinter Review
I just moved several line up-n-down and removed one unneeded SetAuthor() call.

Aso for charset handling, here's problem pieces of code:

GetTopmostMsgWindowCharacterSet(mailCharset, &mCharsetOverride);
if (mailCharset && (* (const PRUnichar *) mailCharset) )
{
  charset.Adopt(ToNewUTF8String(nsDependentString(mailCharset)));
  charsetOverride = PR_TRUE;
}
...
if (!charsetOverride)
{
  rv = msgHdr->GetCharset(getter_Copies(charset));
  if (NS_FAILED(rv)) return rv;
}
...
rv = mimeConverter->DecodeMimeHeader(subjectStr.get(),
	      getter_Copies(decodedString),
	      charset, charsetOverride);

The question is: shouldn't we use Topmost Window Charset only if window
says that charset override is on (mCharsetOverride == PR_TRUE) :
if (mCharsetOverride && mailCharset && (* (const PRUnichar *) mailCharset) ) ?
Keywords: patch, review
*** Bug 109734 has been marked as a duplicate of this bug. ***
Attachment #64142 - Attachment is obsolete: true
Denis, can you post a patch without white space changes using the -w option.
That will make your patch easy to read. Thanks
That's not whitespace noise - I had to move large block of code back and forward.
I think I'll just post patched version tomorrow when I'll come to work... 
Attached patch diff -w version of the above (obsolete) — Splinter Review
Sorry, it turned out to be really ws noise, not complex patch :-)
Here's diff -w output
I am not sure either about the overwrite charset stuff! But the fact you propose
something different for forward that for reply doesn't sound good. One of them
should be bogus!

cc'ing nhotta. Naoki, any advise?
About the patch, I see two problems:
1) Looks like you will set the new message subject for each URI. It should
contains the subject of the first URI and not the one of the last URI.

2) This code become a liitle bit too messy. We should be able to avoid
duplicating code!
I am not sure how this bug is related to charset override. Denis, could you explain?
> But the fact you propose something different for forward that for reply 
> doesn't sound good. One of them should be bogus!
In the case of reply you never get comma separated list of URIs!
JS code just creates separate compose window per selected message.
We can get list of URIs if and only if  we're forwarding as attachment.
Well, I can make this common for all types of composition - loop we'll
be just run once...

> 1) Looks like you will set the new message subject for each URI. It should
> contains the subject of the first URI and not the one of the last URI.
I set subject to space separated list of subjects of messages we're forwarding.
I just didn't know what else it should be. :-) I'll fix it.

> 2) This code become a liitle bit too messy. We should be able to avoid
> duplicating code!
I'll think about this. Do you have any advise or suggestion?




> I am not sure how this bug is related to charset override. Denis, could you 
> explain?
I mean the logic of choosing what charset use for message composition.
Currently it's "If charset override of topmost message window is specified, use
it, otherwise use charset specified in message header". This works for single
message, but what to do with several selected messages? They all may have 
different charsets, so charset override may not work for all of them.
Some of them may not have MIME info in headers...so, how to choose charset?
It seems to me that there is no way to solve this problem for any possible
case. Will it be enough if multi-message forward will only work for messages
with either the same charset for all of them, or correct mime info in headers?
For Reply/Forward override was always set, I recently fixed that problem. 
For multi part, charset of the part is used if specified. If not charset
specified then the default charset is used (forward inline has a bug 66098).
by:
But the fact you propose something different for forward that for reply doesn't
sound good. One of them should be bogus!

I was thinking about the overwrite charset part of the code.

For reply (the current code) we do always user the mail3Pane charset and set
overwrite to true, unless we don' have a mail3Pane charset.

For forward as attachment, you are proposing to use the mail3Pane charset only
if the function GetTopmostMsgWindowCharacterSet() return CharsetOverride to true!

both patch code should do the same and as Naki said, you should match the
existing code. To avoid any trouble with multiple message using different
charset, just use the subject of the first message, that will be the one which
is currently displayed and normally the user would have set the mail3Pane
charset to the correct value if needed.


Attached patch patch, v3 (obsolete) — Splinter Review
How about this one?
Attached patch diff -w version of the above (obsolete) — Splinter Review
As for charset problem, I still don't agree with existing code
(maybe I just don't understand it). 
Current code:
 rv = msgHdr->GetCharset(getter_Copies(charset));

 GetTopmostMsgWindowCharacterSet(mailCharset, &mCharsetOverride);
 if (mailCharset && (* (const PRUnichar *) mailCharset) )
 {
   charset.Adopt(ToNewUTF8String(nsDependentString(mailCharset)));
   charsetOverride = PR_TRUE;
 }

Note that charsetOverride not always equal to mCharsetOverride.
IMO, this code always uses charset of mail window (I assume it's
always set). Why then we ask for msgHdr charset?
Or it's possible for message window to not have charset set?
Well, I don't see much harm in this situation, cause message window
seems to always have right charset (is it true?), but in this case
we can remove unneeded msgHdr->GetCharset.
Am I saying something stupid again?
I think you are right, GetTopmostMsgWindowCharacterSet was added later.
For the override, we used to override always, but now we only override when it's
explicitly requested. So, 'mCharsetOverride' should be used instead of
'charsetOverride' (i.e. 'charsetOverride' can be removed).
I am still not sure this bug is related to any of the charset issue. Is there
test cases of the problem so it can be verified?


I didn't say this bug related to any charset issues :-).
I just was worried about charsetOverride and mCharsetOverride use.
(Huh, I should take few lessons of english :-))
Thanks for clarifying this issue. 
I commented because I worry about changing without test cases. Would you be able
to file a separte bug and fix the charset problem there?
I think possible situations where the current code causes problems could be 
1) the message body charset and the subject header charset is different
2) no charset for message body but the subject has a charset
Let's leave charset handling as is until I perform some testing.
If I'll find problems, I'll file new bug.
Jean-Fransois, could you please review latest patch (v3)?
moving out, but since it's got a patch, we should try to get for 0.9.9
Target Milestone: mozilla0.9.9 → mozilla1.0
I'll review it next week...
Attachment #64273 - Attachment is obsolete: true
Attachment #66264 - Attachment is obsolete: true
*** Bug 127217 has been marked as a duplicate of this bug. ***
>Let's leave charset handling as is until I perform some testing.
>If I'll find problems, I'll file new bug.
>Jean-Fransois, could you please review latest patch (v3)?

Denis, can you post a patch without those charset handling modification. Thanks
See patch, v3 :-)
It doesn't change charset handling
ok, looking at it...
Comment on attachment 66437 [details] [diff] [review]
patch, v3

Looks good and works fine. I have only one little request. Please don't do:
goto DONE, instead do just break; or PR_Free(uriList); break;
Attachment #66437 - Flags: needs-work+
But I need to get out of outer while loop, not only switch statement
Attached patch patch, v3.1 (obsolete) — Splinter Review
Replaced 'goto DONE' with 'PR_FREEIF(uriList); return rv'
Attachment #66437 - Attachment is obsolete: true
Attachment #66438 - Attachment is obsolete: true
Right but that doesn't really matter as you will come back to that same point
for each URL and then just break again. The potential small performance impact
is not important as this is an very unlikly scenario.

My concern is just that the use of goto is very uggly and should be avoided as
much as possible.

BTW, my second proposition should have been:

PR_Free(...)
return;

and not 

PR_Free(...)
break;
oops, I didn't saw your last comment.
The second part of the new patch (@@ -2208,25 +2214,35 @@) seems totally bogus!!!
What's wrong with it? I don't see any problems.
Sorry my mistake, I totally missed the part about ProcessReplyFlags in my review
for patch v3.
Comment on attachment 70968 [details] [diff] [review]
patch, v3.1

R=ducarroz. I am seeking for SR now...

Thanks Denis and sorry again for the confusion during my review.
Attachment #70968 - Flags: review+
*** Bug 127617 has been marked as a duplicate of this bug. ***
Whiteboard: Have fix
&& charset.get() && charset.get()[0])

this can just be !charset.IsEmpty()

Also, the bracing style looks inconsistent - it looks like this file uses this
style:

if (a)
{
}
so you should use it in the new code.

also, you don't need braces if you have single statements in the if then else
clauses.

so 

+            if (NS_SUCCEEDED(rv) && decodedCString) {
+              m_compFields->SetTo(decodedCString);
+            } else {
+              m_compFields->SetTo(author);
+            }

shouldn't have any braces at all.

Other than that, it looks OK.
Attached patch patch, v3.2 (obsolete) — Splinter Review
Code style fixed.
couple more things:
+            if (!isFirstPass)       // safeguard, just in case...
+            {
+              PR_FREEIF(uriList);
+              return rv;
+            }

can just use PR_Free here, since PR_Free checks for null. PR_FREEIF also sets
uriList to null when done, which is a behaviour you don't need here (so it's
just wasted code).

+      if (isFirstPass && !charset.IsEmpty())
+      {
+        m_compFields->SetCharacterSet(charset);
+      }

don't need braces here.

If you fix those things, sr=bienvenu, and I don't need to review it again.
Comment on attachment 71653 [details] [diff] [review]
patch, v3.2

sr=bienvenu, with comments above.
Attachment #71653 - Flags: superreview+
Attached patch patch, v3.3Splinter Review
meet sr= conditions
(PR_FREEIF -> PR_Free and removed braces)
Comment on attachment 71670 [details] [diff] [review]
patch, v3.3

Per previous comment, R=ducarroz, SR=bienvenu.

I'll check it in as soon the tree open for 1.0
Attachment #71670 - Flags: superreview+
Attachment #71670 - Flags: review+
Whiteboard: Have fix → Have fix, need approval
Attachment #70968 - Attachment is obsolete: true
Attachment #71653 - Flags: review+
Attachment #71653 - Attachment is obsolete: true
Attachment #71653 - Flags: review+
Comment on attachment 71670 [details] [diff] [review]
patch, v3.3

a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #71670 - Flags: approval+
Whiteboard: Have fix, need approval → Have fix, ready to go
Fix checked in. Thanks Denis for the patch.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 130030 has been marked as a duplicate of this bug. ***
*** Bug 132983 has been marked as a duplicate of this bug. ***
Just tried this on W2K 2002032203 and all works. You are all wonderful people :-)
Using build 20020322 one winxp, mac 9.1 and linux this is fixed.  I checked IMAP
and POP accounts. Verified
Status: RESOLVED → VERIFIED
*** Bug 137156 has been marked as a duplicate of this bug. ***
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: