Closed Bug 469797 Opened 16 years ago Closed 16 years ago

nsUserInfo::GetFullname assumes ISO-8859-1 name on Linux based systems.

Categories

(Toolkit :: Startup and Profile System, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.1b4

People

(Reporter: standard8, Assigned: standard8)

References

Details

(Keywords: fixed1.9.1, intl)

Attachments

(1 file, 1 obsolete file)

Attached patch The fix (obsolete) — Splinter Review
Split-off from bug 469702 (so that we can track it in TB), when getting a user's full name on Linux if it is non-ascii then it can appear as:

Tomasz SaÅaciÅski

rather than:

Tomasz Sałaciński

nsIUserInfo::fullname is a wstring, and so can clearly support returning the correct value.

getpwuid() returns a struct with the full name in a char*, when we create a copy for returning, we currently use:

*aFullname = ToNewUnicode(fullname);

Replacing this with the UTF-8 version seems to work. I couldn't find any info on particular charsets that getpwuid returns so I assume this is ok.

Also I believe that we don't have a way to do unit tests for this type of function.
Attachment #353192 - Flags: review?(benjamin)
Keywords: intl
Comment on attachment 353192 [details] [diff] [review]
The fix

You can't assume UTF8: you need to use NS_CopyNativeToUnicode
Attachment #353192 - Flags: review?(benjamin) → review-
Attached patch The fix v2Splinter Review
Updated patch, changed to use NS_CopyNativeToUnicode.
Attachment #353192 - Attachment is obsolete: true
Attachment #354623 - Flags: review?(benjamin)
Attachment #354623 - Flags: review?(benjamin) → review+
Checked in: http://hg.mozilla.org/mozilla-central/rev/6870353fe30f
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment on attachment 354623 [details] [diff] [review]
The fix v2

Requesting 1.9.1 branch approval for this simple fix so that we get names displayed correctly in mailnews on Linux when we're trying to guess from the system.

AFAICT Firefox doesn't use this code at the moment, so should be low risk.

No unit tests are possible currently due to this being on a system interface.
Attachment #354623 - Flags: approval1.9.1?
Summary: nsUserInfo::GetFullname assumes ASCII name on Linux based systems. → nsUserInfo::GetFullname assumes ISO-8859-1 name on Linux based systems.
(In reply to comment #4)
> (From update of attachment 354623 [details] [diff] [review])
> AFAICT Firefox doesn't use this code at the moment, so should be low risk.
> 
> No unit tests are possible currently due to this being on a system interface.

Note: this can be tested manually on Firefox (or any toolkit application).

Set up a login on Linux with non-ascii/iso-8859-1 characters in the full name of the login. The startup Firefox/SeaMonkey/Thunderbird and enter the following into the error console and select evaluate:

alert(Components.classes["@mozilla.org/userinfo;1"].getService(Components.interfaces.nsIUserInfo).fullname)

If the patch is applied, the non-ascii/iso-8859-1 characters will be displayed properly.

On Thunderbird/SeaMonkey, bringing up the Account Manager and selecting to add a new email account is an alternative way to check it (again, the Full Name is displayed there - which is what we are trying to fix).
Comment on attachment 354623 [details] [diff] [review]
The fix v2

a191=beltzner
Attachment #354623 - Flags: approval1.9.1? → approval1.9.1+
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/c6e0ec0a708c
Keywords: fixed1.9.1
Target Milestone: mozilla1.9.1b3 → mozilla1.9.1b4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: