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.
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.
*Only the last "single" & actually underlines the next character.
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['@mozilla.org/messenger/osintegration;1']
Created attachment 635699 [details] [diff] [review]
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 on attachment 635699 [details] [diff] [review]
you could make the function static, since it's fairly specific to this file...
Pushed comm-central changeset 7198d5992627.
Oops, why did I forgot to mark this as FIXED?