Comment 54 for bug 85579

Revision history for this message
In , Cavin (cavin) wrote :

OK, here are the reasons why:
1. In nsMsgLocalMailFolder::CreateSubfolder() we call
NS_MsgHashAutoStringIfNecessary() directly to make sure that we have a safe
folder name to create .msf file and the msg file (ie, 'aa.msg' and 'aa'). The
string passed to NS_MsgHashAutoStringIfNecessary() is the one entered by the
users (ie, no conversion is performed on it) and for this reason
nsMsgI18Ncheck_data_in_charset_range() returns TRUE because Chinese string is
supported by Chinese windows. At this point we have created .msf and msg files
on disk. So far so good.

2. Then in nsMsgLocalMailFolder::CreateSubfolder() we call AddSubfolder() which
eventually calls NS_MsgCreatePathStringFromFolderURI(). The latter does some
string manipulations and calls NS_MsgHashIfNecessary().
NS_MsgHashIfNecessary() then converts the input C string to nsAUtoString before
calling NS_MsgHashAutoStringIfNecessary(). So by the time we try to check if the
folder name will convert to the underlying OS the string is altered and the call
to nsMsgI18Ncheck_data_in_charset_range()fails! Since the call fails the name
is hashed and all the subsequent calls to open the folder database fails as
well. This is because in step one we create the .msf file with the original name
the users entered and now we try to open the database with a different (hashed)
name. The problem is really that the string passed to
NS_MsgHashAutoStringIfNecessary() (called by NS_MsgHashIfNecessary()) does not
represent a correct Chinese string.

To fix the problem we need to make NS_MsgCreatePathStringFromFolderURI() call
NS_MsgHashAutoStringIfNecessary() directly (instead of NS_MsgHashIfNecessary()).
But then we need to change NS_MsgCreatePathStringFromFolderURI() to use
nsAutoString instead of nsCAutoSting.

Commenting out the call to nsMsgI18Ncheck_data_in_charset_range(), the patch
works for the following (tested) cases of folder creation:
1. ASCII folders in English windows.
2. Chiness folders in Chiness windows.

However, with the call to nsMsgI18Ncheck_data_in_charset_range() it does not
work for the following cases of folder creation:
1. Chiness folders in English windows.
2. Chiness folders in Chiness windows.