Nmap Development mailing list archives

Re: Non-ASCII user names on Windows; internationalization fun


From: David Fifield <david () bamsoftware com>
Date: Sun, 14 Sep 2008 13:40:20 -0600

On Sun, Sep 14, 2008 at 08:20:47PM +0200, Dirk Loss wrote:
David Fifield wrote:
Currently we use os.path.expanduser("~"), decoded from the filesystem 
encoding, to get the user's home directory.
os.path.expanduser reads the environment variable HOME, which simply
doesn't work for users with the names we've discussed. You get back a
bunch of question marks. If someone knows a good way to get the home
directory using the Python standard library, I'm all ears.

Googling turned up this potential solution [1]:
home = os.path.expanduser("~").decode(sys.getfilesystemencoding())

I haven't been able to test whether it really works, though.

Thanks for doing some research. Zenmap already uses that solution. See
zenmapCore/BasePaths.py:

    fs_enc = sys.getfilesystemencoding()
    if fs_enc is None:
        fs_enc = "UTF-8"
    raw_home = os.path.expanduser("~")
    home = raw_home.decode(fs_enc)

But it doesn't work for my user with the Japanese name, unless the
system locale is set to Japanese. My guess is that with the locale set
to English, the filesystem encoding can't even represent the Japanese
characters. They are replaced with '?'. The error Zenmap gives you in
this case is one that comes from Windows, essentially saying that '?' is
not legal in a file name.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: