Bug #343179 --> pass keyword strings around instead of the actual tag name to avoid some encoding issues when using english builds with profiles created using other languages. Thanks to Alexander Ihrig for his help with this. sr=bienvenu

This commit is contained in:
scott%scott-macgregor.org 2006-07-05 17:50:19 +00:00
parent 6e04dcb15d
commit cf4dd538b6
2 changed files with 15 additions and 14 deletions

View File

@ -536,19 +536,16 @@ function setTagHeader()
if (label > 0) if (label > 0)
{ {
var labelTag = '$label' + label; var labelTag = '$label' + label;
if (!tags.search(labelTag)) // don't add the label if it's already in our keyword list if (!tags || !tags.search(labelTag)) // don't add the label if it's already in our keyword list
tagsString = encodeURIComponent(gPrefBranch.getComplexValue("mailnews.labels.description." + label, tagsString = labelTag;
Components.interfaces.nsIPrefLocalizedString).data);
} }
// now convert the list of tag ids into user presentable strings, separate by commas // rebuild the keywords string with just the keys that are
// actual tags and not other keywords like Junk and NonJunk.
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"] var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService); .getService(Components.interfaces.nsIMsgTagService);
// tokenize the keywords based on ' '
var tagsArray = tags.split(' '); var tagsArray = tags.split(' ');
for (var index = 0; index < tagsArray.length; index++) for (var index = 0; index < tagsArray.length; index++)
{
if (tagsArray[index])
{ {
var tagName; var tagName;
try { try {
@ -561,8 +558,7 @@ function setTagHeader()
{ {
if (tagsString) if (tagsString)
tagsString += " "; tagsString += " ";
tagsString += encodeURIComponent(tagName); tagsString += tagsArray[index];
}
} }
} }

View File

@ -982,20 +982,25 @@
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"] var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService); .getService(Components.interfaces.nsIMsgTagService);
// tokenize the keywords based on ' ' // tokenize the keywords based on ' '
var tagsArray = aTags.split(' '); var tagsArray = aTags.split(' ');
var decodedTagName;
for (var index = 0; index < tagsArray.length; index++) for (var index = 0; index < tagsArray.length; index++)
{ {
// for each tag, create a label, give it the font color that corresponds to the // for each tag, create a label, give it the font color that corresponds to the
// color of the tag and append it. // color of the tag and append it.
decodedTagName = decodeURIComponent(tagsArray[index]); var tagName;
var tagKey = tagService.getKeyForTag(decodedTagName); try {
var color = tagService.getColorForKey(tagKey); // if we got a bad tag name, getTagForKey will throw an exception, skip it
// and go to the next one.
tagName = tagService.getTagForKey(tagsArray[index]);
} catch (ex) { continue; }
var color = tagService.getColorForKey(tagsArray[index]);
// now create a label for the tag name, and set the color // now create a label for the tag name, and set the color
var label = document.createElement("label"); var label = document.createElement("label");
label.setAttribute('value', decodedTagName); label.setAttribute('value', tagName);
label.style.color = color; label.style.color = color;
label.className = "tagvalue"; label.className = "tagvalue";
headerValueNode.appendChild(label); headerValueNode.appendChild(label);