As I reported in my contributions to that forum thread the code of
TLuaInterpreter::getHomeDir() will be mangling what M$ Windoze now
permits to be used for User names.  It is not yet clear to me at what
point that operating system allowed user-names and thus the user
directories that are created to contain non-ASCII characters.  For *nix
OSes the POSIX.1-2008 specifications (IEEE Std 1003.1-2008)
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_431
limit the characters to a portable set of characters that is basically
ASCII with some changes.

<aside> Indeed when I tried to create a user name the same as mentioned
on the forum thread I actually found a bug in the adduser(8) script on
my Debian system that prevented such a name to be created EVEN WITH the
option to force the use of the non-ASCII characters!  An awk script
correction was necessary and I think other things might be playing up so
what follows will need to be tested on a system comparable to the
OP's...</aside>

Anyhow, I think we may be able to fix this by changing from .toLatin1()
to .toUtf8() in this method:

int TLuaInterpreter::getMudletHomeDir( lua_State * L )
{
    QString home = QDir::homePath();
    home.append( "/.config/mudlet/profiles/" );
    Host * pHost = TLuaInterpreter::luaInterpreterMap[L];
    QString name = pHost->getName();
    home.append( name );
    QString erg = QDir::toNativeSeparators( home );
    lua_pushstring( L, erg.toLatin1().data() );
    return 1;
}

I.E. change from:
    lua_pushstring( L, erg.toLatin1().data() );
to:
    lua_pushstring( L, erg.toUtf8().data() );

This does assume that Qt will correctly process the information it gets
from the system, but if not, from at least Qt4.8, there is a way to
falsify the idea that it has of the user's home directory so that an
alternative location could be specified which could be constructed with
only ASCII characters.  See, for example, the "QString QDir::homePath ()
[static]" entry on http://qt-project.org/doc/qt-4.8/qdir.html.

-- 
You received this bug notification because you are a member of Mudlet
Makers, which is subscribed to Mudlet.
https://bugs.launchpad.net/bugs/1322753

Title:
  getMudletHomeDir() has problems with nonstandard characters in path

Status in Mudlet the MUD client:
  Confirmed

Bug description:
  Mudlet 2.1
  Windows XP, Czech (not sure about version, as I am typing this from another 
computer)

  As described in this post:
  http://forums.mudlet.org/viewtopic.php?f=9&t=4508 getMudletHomeDir()
  will not match the actual path if the path contains certain special
  characters (encoding problem).

To manage notifications about this bug go to:
https://bugs.launchpad.net/mudlet/+bug/1322753/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~mudlet-makers
Post to     : mudlet-makers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mudlet-makers
More help   : https://help.launchpad.net/ListHelp

Reply via email to