Bug 410610 - Can't open a local HTML file that has accents (special unicode characters) in its filename, r=luser+Neil

This commit is contained in:
benjamin%smedbergs.us 2008-01-07 16:38:12 +00:00
Родитель ee7de8b1d4
Коммит 9f0a58843c
7 изменённых файлов: 44 добавлений и 68 удалений

Просмотреть файл

@ -686,30 +686,7 @@ nsToolkitProfileService::CreateProfile(nsILocalFile* aRootDir,
return NS_ERROR_FILE_NOT_DIRECTORY; return NS_ERROR_FILE_NOT_DIRECTORY;
} }
else { else {
nsCOMPtr<nsIFile> profileDefaultsDir; rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
nsCOMPtr<nsIFile> profileDirParent;
nsCAutoString profileDirName;
rv = rootDir->GetParent(getter_AddRefs(profileDirParent));
NS_ENSURE_SUCCESS(rv, rv);
rv = rootDir->GetNativeLeafName(profileDirName);
NS_ENSURE_SUCCESS(rv, rv);
PRBool dummy;
rv = gDirServiceProvider->GetFile(NS_APP_PROFILE_DEFAULTS_50_DIR, &dummy,
getter_AddRefs(profileDefaultsDir));
if (NS_SUCCEEDED(rv))
rv = profileDefaultsDir->CopyToNative(profileDirParent,
profileDirName);
if (NS_FAILED(rv)) {
// if copying failed, lets just ensure that the profile directory exists.
rv = rootDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = rootDir->SetPermissions(0700);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }

Просмотреть файл

@ -131,7 +131,7 @@ endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows) ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS += nsNativeAppSupportWin.cpp CPPSRCS += nsNativeAppSupportWin.cpp
DEFINES += -DWIN32_LEAN_AND_MEAN DEFINES += -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE
else else
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa) ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = nsNativeAppSupportCocoa.mm CMMSRCS = nsNativeAppSupportCocoa.mm

Просмотреть файл

@ -392,7 +392,7 @@ static void Output(PRBool isError, const char *fmt, ... )
flags |= MB_ICONERROR; flags |= MB_ICONERROR;
else else
flags |= MB_ICONINFORMATION; flags |= MB_ICONINFORMATION;
MessageBox(NULL, msg, "XULRunner", flags); MessageBoxA(NULL, msg, "XULRunner", flags);
PR_smprintf_free(msg); PR_smprintf_free(msg);
} }
#else #else

Просмотреть файл

@ -129,7 +129,7 @@ struct Mutex {
: mName( name ), : mName( name ),
mHandle( 0 ), mHandle( 0 ),
mState( -1 ) { mState( -1 ) {
mHandle = CreateMutex( 0, FALSE, mName.get() ); mHandle = CreateMutexA( 0, FALSE, mName.get() );
#if MOZ_DEBUG_DDE #if MOZ_DEBUG_DDE
printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() ); printf( "CreateMutex error = 0x%08X\n", (int)GetLastError() );
#endif #endif
@ -328,8 +328,8 @@ private:
ULONG dwData1, ULONG dwData1,
ULONG dwData2 ); ULONG dwData2 );
static void HandleCommandLine(const char* aCmdLineString, nsIFile* aWorkingDir, PRUint32 aState); static void HandleCommandLine(const char* aCmdLineString, nsIFile* aWorkingDir, PRUint32 aState);
static void ParseDDEArg( HSZ args, int index, nsCString& string); static void ParseDDEArg( HSZ args, int index, nsString& string);
static void ParseDDEArg( const char* args, int index, nsCString& aString); static void ParseDDEArg( const WCHAR* args, int index, nsString& aString);
static void ActivateLastWindow(); static void ActivateLastWindow();
static HDDEDATA CreateDDEData( DWORD value ); static HDDEDATA CreateDDEData( DWORD value );
static HDDEDATA CreateDDEData( LPBYTE value, DWORD len ); static HDDEDATA CreateDDEData( LPBYTE value, DWORD len );
@ -487,7 +487,7 @@ struct MessageWindow {
// ctor/dtor are simplistic // ctor/dtor are simplistic
MessageWindow() { MessageWindow() {
// Try to find window. // Try to find window.
mHandle = ::FindWindow( className(), 0 ); mHandle = ::FindWindowA( className(), 0 );
} }
// Act like an HWND. // Act like an HWND.
@ -512,7 +512,7 @@ struct MessageWindow {
// Create: Register class and create window. // Create: Register class and create window.
NS_IMETHOD Create() { NS_IMETHOD Create() {
WNDCLASS classStruct = { 0, // style WNDCLASSA classStruct = { 0, // style
&MessageWindow::WindowProc, // lpfnWndProc &MessageWindow::WindowProc, // lpfnWndProc
0, // cbClsExtra 0, // cbClsExtra
0, // cbWndExtra 0, // cbWndExtra
@ -524,10 +524,10 @@ struct MessageWindow {
className() }; // lpszClassName className() }; // lpszClassName
// Register the window class. // Register the window class.
NS_ENSURE_TRUE( ::RegisterClass( &classStruct ), NS_ERROR_FAILURE ); NS_ENSURE_TRUE( ::RegisterClassA( &classStruct ), NS_ERROR_FAILURE );
// Create the window. // Create the window.
NS_ENSURE_TRUE( ( mHandle = ::CreateWindow( className(), NS_ENSURE_TRUE( ( mHandle = ::CreateWindowA(className(),
0, // title 0, // title
WS_CAPTION, // style WS_CAPTION, // style
0,0,0,0, // x, y, cx, cy 0,0,0,0, // x, y, cx, cy
@ -721,7 +721,7 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) {
PRBool PRBool
nsNativeAppSupportWin::InitTopicStrings() { nsNativeAppSupportWin::InitTopicStrings() {
for ( int i = 0; i < topicCount; i++ ) { for ( int i = 0; i < topicCount; i++ ) {
if ( !( mTopics[ i ] = DdeCreateStringHandle( mInstance, const_cast<char *>(topicNames[ i ]), CP_WINANSI ) ) ) { if ( !( mTopics[ i ] = DdeCreateStringHandleA( mInstance, const_cast<char *>(topicNames[ i ]), CP_WINANSI ) ) ) {
return PR_FALSE; return PR_FALSE;
} }
} }
@ -761,7 +761,7 @@ nsNativeAppSupportWin::StartDDE() {
NS_ERROR_FAILURE ); NS_ERROR_FAILURE );
// Allocate DDE strings. // Allocate DDE strings.
NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, (char*) gAppData->name, CP_WINANSI ) ) && InitTopicStrings(), NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandleA( mInstance, (char*) gAppData->name, CP_WINANSI ) ) && InitTopicStrings(),
NS_ERROR_FAILURE ); NS_ERROR_FAILURE );
// Next step is to register a DDE service. // Next step is to register a DDE service.
@ -992,26 +992,26 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
// Open a given URL... // Open a given URL...
// Get the URL from the first argument in the command. // Get the URL from the first argument in the command.
nsCAutoString url; nsAutoString url;
ParseDDEArg(hsz2, 0, url); ParseDDEArg(hsz2, 0, url);
// Read the 3rd argument in the command to determine if a // Read the 3rd argument in the command to determine if a
// new window is to be used. // new window is to be used.
nsCAutoString windowID; nsAutoString windowID;
ParseDDEArg(hsz2, 2, windowID); ParseDDEArg(hsz2, 2, windowID);
// "" means to open the URL in a new window. // "" means to open the URL in a new window.
if ( windowID.Equals( "" ) ) { if ( windowID.IsEmpty() ) {
url.Insert("mozilla -new-window ", 0); url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
} }
else { else {
url.Insert("mozilla -url ", 0); url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
} }
#if MOZ_DEBUG_DDE #if MOZ_DEBUG_DDE
printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() ); printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
#endif #endif
// Now handle it. // Now handle it.
HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT); HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
// Return pseudo window ID. // Return pseudo window ID.
result = CreateDDEData( 1 ); result = CreateDDEData( 1 );
@ -1109,12 +1109,12 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
} }
case topicActivate: { case topicActivate: {
// Activate a Nav window... // Activate a Nav window...
nsCAutoString windowID; nsAutoString windowID;
ParseDDEArg(hsz2, 0, windowID); ParseDDEArg(hsz2, 0, windowID);
// 4294967295 is decimal for 0xFFFFFFFF which is also a // 4294967295 is decimal for 0xFFFFFFFF which is also a
// correct value to do that Activate last window stuff // correct value to do that Activate last window stuff
if ( windowID.Equals( "-1" ) || if ( windowID.EqualsLiteral( "-1" ) ||
windowID.Equals( "4294967295" ) ) { windowID.EqualsLiteral( "4294967295" ) ) {
// We only support activating the most recent window (or a new one). // We only support activating the most recent window (or a new one).
ActivateLastWindow(); ActivateLastWindow();
// Return pseudo window ID. // Return pseudo window ID.
@ -1163,26 +1163,26 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
// Default is to open in current window. // Default is to open in current window.
PRBool new_window = PR_FALSE; PRBool new_window = PR_FALSE;
nsCAutoString url; nsAutoString url;
ParseDDEArg((const char*) request, 0, url); ParseDDEArg((const WCHAR*) request, 0, url);
// Read the 3rd argument in the command to determine if a // Read the 3rd argument in the command to determine if a
// new window is to be used. // new window is to be used.
nsCAutoString windowID; nsAutoString windowID;
ParseDDEArg((const char*) request, 2, windowID); ParseDDEArg((const WCHAR*) request, 2, windowID);
// "" means to open the URL in a new window. // "" means to open the URL in a new window.
if ( windowID.Equals( "" ) ) { if ( windowID.IsEmpty() ) {
url.Insert("mozilla -new-window ", 0); url.Insert(NS_LITERAL_STRING("mozilla -new-window "), 0);
} }
else { else {
url.Insert("mozilla -url ", 0); url.Insert(NS_LITERAL_STRING("mozilla -url "), 0);
} }
#if MOZ_DEBUG_DDE #if MOZ_DEBUG_DDE
printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() ); printf( "Handling dde XTYP_REQUEST request: [%s]...\n", NS_ConvertUTF16toUTF8(url).get() );
#endif #endif
// Now handle it. // Now handle it.
HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT); HandleCommandLine(NS_ConvertUTF16toUTF8(url).get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
// Release the data. // Release the data.
DdeUnaccessData( hdata ); DdeUnaccessData( hdata );
@ -1204,7 +1204,7 @@ nsNativeAppSupportWin::HandleDDENotification( UINT uType, // transaction t
// if the closing '"' is missing) if the arg is quoted. If the arg // if the closing '"' is missing) if the arg is quoted. If the arg
// is not quoted, then p+result will point to the first character // is not quoted, then p+result will point to the first character
// of the arg. // of the arg.
static PRInt32 advanceToEndOfQuotedArg( const char *p, PRInt32 offset, PRInt32 len ) { static PRInt32 advanceToEndOfQuotedArg( const WCHAR *p, PRInt32 offset, PRInt32 len ) {
// Check whether the current arg is quoted. // Check whether the current arg is quoted.
if ( p[++offset] == '"' ) { if ( p[++offset] == '"' ) {
// Advance past the closing quote. // Advance past the closing quote.
@ -1219,17 +1219,16 @@ static PRInt32 advanceToEndOfQuotedArg( const char *p, PRInt32 offset, PRInt32 l
return offset; return offset;
} }
void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString& aString) { void nsNativeAppSupportWin::ParseDDEArg( const WCHAR* args, int index, nsString& aString) {
if ( args ) { if ( args ) {
int argLen = strlen(args); nsDependentString temp(args);
nsDependentCString temp(args, argLen);
// offset points to the comma preceding the desired arg. // offset points to the comma preceding the desired arg.
PRInt32 offset = -1; PRInt32 offset = -1;
// Skip commas till we get to the arg we want. // Skip commas till we get to the arg we want.
while( index-- ) { while( index-- ) {
// If this arg is quoted, then go to closing quote. // If this arg is quoted, then go to closing quote.
offset = advanceToEndOfQuotedArg( args, offset, argLen); offset = advanceToEndOfQuotedArg( args, offset, temp.Length());
// Find next comma. // Find next comma.
offset = temp.FindChar( ',', offset ); offset = temp.FindChar( ',', offset );
if ( offset == kNotFound ) { if ( offset == kNotFound ) {
@ -1246,12 +1245,12 @@ void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString&
// deal with that before searching for the terminating comma. // deal with that before searching for the terminating comma.
// We advance offset so it ends up pointing to the start of // We advance offset so it ends up pointing to the start of
// the argument we want. // the argument we want.
PRInt32 end = advanceToEndOfQuotedArg( args, offset++, argLen ); PRInt32 end = advanceToEndOfQuotedArg( args, offset++, temp.Length() );
// Find next comma (or end of string). // Find next comma (or end of string).
end = temp.FindChar( ',', end ); end = temp.FindChar( ',', end );
if ( end == kNotFound ) { if ( end == kNotFound ) {
// Arg is the rest of the string. // Arg is the rest of the string.
end = argLen; end = temp.Length();
} }
// Extract result. // Extract result.
aString.Assign( args + offset, end - offset ); aString.Assign( args + offset, end - offset );
@ -1260,15 +1259,15 @@ void nsNativeAppSupportWin::ParseDDEArg( const char* args, int index, nsCString&
} }
// Utility to parse out argument from a DDE item string. // Utility to parse out argument from a DDE item string.
void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsCString& aString) { void nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index, nsString& aString) {
DWORD argLen = DdeQueryString( mInstance, args, NULL, NULL, CP_WINANSI ); DWORD argLen = DdeQueryStringW( mInstance, args, NULL, NULL, CP_WINUNICODE );
// there wasn't any string, so return empty string // there wasn't any string, so return empty string
if ( !argLen ) return; if ( !argLen ) return;
nsCAutoString temp; nsAutoString temp;
// Ensure result's buffer is sufficiently big. // Ensure result's buffer is sufficiently big.
temp.SetLength( argLen ); temp.SetLength( argLen );
// Now get the string contents. // Now get the string contents.
DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINANSI ); DdeQueryString( mInstance, args, temp.BeginWriting(), temp.Length(), CP_WINUNICODE );
// Parse out the given arg. // Parse out the given arg.
ParseDDEArg(temp.get(), index, aString); ParseDDEArg(temp.get(), index, aString);
return; return;

Просмотреть файл

@ -235,7 +235,7 @@ AllocConvertUTF8toUTF16(const char *arg)
ConvertUTF8toUTF16 convert(s); ConvertUTF8toUTF16 convert(s);
convert.write(arg, len); convert.write(arg, len);
s[len] = '\0'; convert.write_terminator();
return s; return s;
} }

Просмотреть файл

@ -23,7 +23,7 @@ AllocConvertUTF16toUTF8(const WCHAR *arg)
ConvertUTF16toUTF8 convert(s); ConvertUTF16toUTF8 convert(s);
convert.write(arg, len); convert.write(arg, len);
s[len] = '\0'; convert.write_terminator();
return s; return s;
} }

Просмотреть файл

@ -70,7 +70,7 @@ printf("\n****Inside ShowOSAlert ***\n");
message_copy[copy_len] = 0; message_copy[copy_len] = 0;
#if defined (XP_WIN) #if defined (XP_WIN)
MessageBox(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND ); MessageBoxA(NULL, message_copy, NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND );
#elif (XP_MAC) #elif (XP_MAC)
short buttonClicked; short buttonClicked;
StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked); StandardAlert(kAlertStopAlert, c2pstr(message_copy), nil, nil, &buttonClicked);