Opened 15 years ago

Closed 15 years ago

#1118 closed defect (fixed)

Alias with unicode path can't work

Reported by: christinebao Owned by: Christine Bao
Priority: medium Milestone: 2.2
Component: General Version: 2.0.2
Severity: major Keywords:
Cc: Chris Claydon External ID: 1262444

Description

Steps to reproduce:

  1. Create a folder with unicode name, for example "c:\测试". Put an SDF file in this folder for example City_Boundary.sdf (any SDF works).
  2. In MG Site Administrator page, create an alias, for example: Unicode=c:\测试.
  3. Open MG Studio, create an SDF connection, choose %MG_DATA_PATH_ALIAS[Unicode]%/City_Boundary.sdf. Try "Test connection".

Result:
An exception shows: the SDF file doesn't exist or can't be opened in access mode.

If choose other provider files, none of them can be connected, and they will show different error message. The key point is: the alias represents a folder with unicode name.

Attachments (1)

UnicodeAlias.patch (904 bytes ) - added by christinebao 15 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by christinebao, 15 years ago

Tech diagnosis:
The defect happens in UnmanagedDataManager.cpp,

int MgUnmanagedDataManager::SubstituteDataPathAliases(string& doc)
{
    //some code
                    STRING mappingDir = stringProp->GetValue();

                    // replace the mappingName with the actual directory
                    if (!MgFileUtil::EndsWithSlash(mappingDir))
                        MgFileUtil::AppendSlashToEndOfPath(mappingDir);

                    size_t dirLen = mappingDir.length();

                    doc.replace(startPos, len1 + nameLen + len2, MgUtil::WideCharToMultiByte(mappingDir), 0, dirLen);
    //some code
}

mappingDir is STRING type, which stands for std::wstring. However doc stands for string and composited by char. So use the size of mappingDir to replace the content in doc causing path to be cut off.

To fix this, mappingDir should be converted to string type first and then replace the content in doc.

by christinebao, 15 years ago

Attachment: UnicodeAlias.patch added

comment:3 by christinebao, 15 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.