As a security precaution, we have turned on the setting "Require API key authentication for API requests" for everyone. If this has broken something, please contact
Last Comment Bug 767323 - Ampersands don't appear in the windows biff icon tooltip
: Ampersands don't appear in the windows biff icon tooltip
Product: MailNews Core
Classification: Components
Component: Backend (show other bugs)
: Trunk
: x86_64 Windows 7
: -- minor (vote)
: Thunderbird 16.0
Assigned To:
Depends on:
  Show dependency treegraph
Reported: 2012-06-22 04:32 PDT by
Modified: 2012-09-26 03:54 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---

Proposed patch (2.99 KB, patch)
2012-06-22 05:21 PDT,
mozilla: review+
Details | Diff | Splinter Review

Description User image 2012-06-22 04:32:08 PDT
I happened to notice a feed in my biff icon tooltip. However the name of the account, "Blogs & News Feeds" had been corrupted - the ampersand was missing.

A search turned up the problem was a "feature" of tooltips - they delete ampersands because people writing for native Win32 use the same string for a control's label as for its tooltip, so they want the ampersand removed.

There is a way to disable this for a custom tooltip, but we're stuck with the default tooltip created by Windows Explorer.
Comment 1 User image 2012-06-22 04:39:44 PDT
OK, so the rule is a little more complicated than that.

The tooltip code removes one & from any run of &s.
However the underlining code also affects the display.
It allows you to quote an & with another &.
So in all you need 2n+1 &s for each run of &s.

Input	Display*
&&	_
&&&	&
&&&&	&_
&&&&&	&&
&&&&&&	&&_
&&&&&&&	&&&

*Only the last "single" & actually underlines the next character.
Comment 2 User image 2012-06-22 05:12:50 PDT
To test biff, I open a folder (not an account) and evaluate (on one line):
top.opener.msgWindow.openFolder.server.performingBiff = true;
var Ci = Components.interfaces;
var mwi = Components.classes[';1']
Comment 3 User image 2012-06-22 05:21:15 PDT
Created attachment 635699 [details] [diff] [review]
Proposed patch

I decided to fix the hard case with multiple ampersands, just in case ;-)

After replacing single ampersands with three, I then search for six ampersands, which must come from (part of) a run of ampersands. I delete one, then skip two, so that I delete one in every three as long as there are at least six.

2 -> 6 -> 5 (less than 6, so stop)
3 -> 9 -> 2 + 6 -> 2 + 5 (less than 6, so stop) -> 7
4 -> 12 -> 2 + 9 -> 2 + 2 + 6 -> 2 + 2 + 5 -> 9 etc.

Of course, only when we have properly escaped the string can we actually check whether it will fit in the notification buffer.
Comment 4 User image David :Bienvenu 2012-06-25 15:49:37 PDT
Comment on attachment 635699 [details] [diff] [review]
Proposed patch

you could make the function static, since it's fairly specific to this file...
Comment 5 User image 2012-06-26 01:36:35 PDT
Pushed comm-central changeset 7198d5992627.
Comment 6 User image 2012-07-02 09:52:15 PDT
Oops, why did I forgot to mark this as FIXED?

Note You need to log in before you can comment on or make changes to this bug.