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,20 +536,17 @@ function setTagHeader()
if (label > 0)
{
var labelTag = '$label' + label;
if (!tags.search(labelTag)) // don't add the label if it's already in our keyword list
tagsString = encodeURIComponent(gPrefBranch.getComplexValue("mailnews.labels.description." + label,
Components.interfaces.nsIPrefLocalizedString).data);
if (!tags || !tags.search(labelTag)) // don't add the label if it's already in our keyword list
tagsString = labelTag;
}
// 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"]
.getService(Components.interfaces.nsIMsgTagService);
// tokenize the keywords based on ' '
var tagsArray = tags.split(' ');
for (var index = 0; index < tagsArray.length; index++)
{
if (tagsArray[index])
{
var tagName;
try {
// if we got a bad tag name, getTagForKey will throw an exception, skip it
@ -561,8 +558,7 @@ function setTagHeader()
{
if (tagsString)
tagsString += " ";
tagsString += encodeURIComponent(tagName);
}
tagsString += tagsArray[index];
}
}

View File

@ -982,20 +982,25 @@
var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"]
.getService(Components.interfaces.nsIMsgTagService);
// tokenize the keywords based on ' '
var tagsArray = aTags.split(' ');
var decodedTagName;
for (var index = 0; index < tagsArray.length; index++)
{
// for each tag, create a label, give it the font color that corresponds to the
// color of the tag and append it.
decodedTagName = decodeURIComponent(tagsArray[index]);
var tagKey = tagService.getKeyForTag(decodedTagName);
var color = tagService.getColorForKey(tagKey);
var tagName;
try {
// 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
var label = document.createElement("label");
label.setAttribute('value', decodedTagName);
label.setAttribute('value', tagName);
label.style.color = color;
label.className = "tagvalue";
headerValueNode.appendChild(label);