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

RESOLVED FIXED in mozilla1.9.1b4

Status

()

Toolkit
Startup and Profile System
RESOLVED FIXED
10 years ago
9 years ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

({fixed1.9.1, intl})

Trunk
mozilla1.9.1b4
x86
Linux
fixed1.9.1, intl
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

823 bytes, patch
Benjamin Smedberg
: review+
beltzner
: approval1.9.1+
Details | Diff | Splinter Review
(Assignee)

Description

10 years ago
Created attachment 353192 [details] [diff] [review]
The fix

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)
(Assignee)

Updated

10 years ago
Keywords: intl

Comment 1

10 years ago
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-
(Assignee)

Comment 2

9 years ago
Created attachment 354623 [details] [diff] [review]
The fix v2

Updated patch, changed to use NS_CopyNativeToUnicode.
Attachment #353192 - Attachment is obsolete: true
Attachment #354623 - Flags: review?(benjamin)

Updated

9 years ago
Attachment #354623 - Flags: review?(benjamin) → review+
(Assignee)

Comment 3

9 years ago
Checked in: http://hg.mozilla.org/mozilla-central/rev/6870353fe30f
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
(Assignee)

Comment 4

9 years ago
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?

Updated

9 years ago
Duplicate of this bug: 334488

Updated

9 years ago
Summary: nsUserInfo::GetFullname assumes ASCII name on Linux based systems. → nsUserInfo::GetFullname assumes ISO-8859-1 name on Linux based systems.
(Assignee)

Comment 6

9 years ago
(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+
(Assignee)

Comment 8

9 years ago
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.