From 318955603b356aab601e19d26fa5b5e90ab22d6a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2012 23:54:15 +0000 Subject: [PATCH 1/1] Ensure that paths used inside wxOSX are always in NFC form. OSX uses NFKD but this is unexpected for wx applications, so normalize the string to use the composed form whenever we receive a file system path from OS X. Closes #13504. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/dirdlg.mm | 2 +- src/osx/cocoa/filedlg.mm | 4 ++-- src/osx/cocoa/utils.mm | 2 +- src/osx/core/stdpaths_cf.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/osx/cocoa/dirdlg.mm b/src/osx/cocoa/dirdlg.mm index 700969c3ee..ad757e2adc 100644 --- a/src/osx/cocoa/dirdlg.mm +++ b/src/osx/cocoa/dirdlg.mm @@ -120,7 +120,7 @@ void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode) if (returnCode == NSOKButton ) { NSOpenPanel* oPanel = (NSOpenPanel*)panel; - SetPath( wxCFStringRef::AsString([[oPanel filenames] objectAtIndex:0])); + SetPath( wxCFStringRef::AsStringWithNormalizationFormC([[oPanel filenames] objectAtIndex:0])); result = wxID_OK; } SetReturnCode(result); diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index 6e4e5c4f2c..40fd8c4294 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -651,7 +651,7 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) NSSavePanel* sPanel = (NSSavePanel*)panel; result = wxID_OK; - m_path = wxCFStringRef::AsString([sPanel filename]); + m_path = wxCFStringRef::AsStringWithNormalizationFormC([sPanel filename]); m_fileName = wxFileNameFromPath(m_path); m_dir = wxPathOnly( m_path ); if (m_filterChoice) @@ -670,7 +670,7 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) NSArray* filenames = [oPanel filenames]; for ( size_t i = 0 ; i < [filenames count] ; ++ i ) { - wxString fnstr = wxCFStringRef::AsString([filenames objectAtIndex:i]); + wxString fnstr = wxCFStringRef::AsStringWithNormalizationFormC([filenames objectAtIndex:i]); m_paths.Add( fnstr ); m_fileNames.Add( wxFileNameFromPath(fnstr) ); if ( i == 0 ) diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index ef5aefa538..8b80a601b1 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -71,7 +71,7 @@ void wxBell() const size_t count = [fileNames count]; for (i = 0; i < count; i++) { - fileList.Add( wxCFStringRef::AsString([fileNames objectAtIndex:i]) ); + fileList.Add( wxCFStringRef::AsStringWithNormalizationFormC([fileNames objectAtIndex:i]) ); } wxTheApp->MacOpenFiles(fileList); diff --git a/src/osx/core/stdpaths_cf.cpp b/src/osx/core/stdpaths_cf.cpp index de312789c9..f5bf602b11 100644 --- a/src/osx/core/stdpaths_cf.cpp +++ b/src/osx/core/stdpaths_cf.cpp @@ -83,7 +83,7 @@ static wxString BundleRelativeURLToPath(CFURLRef relativeURL) wxCHECK_MSG(absoluteURL, wxEmptyString, wxT("Failed to resolve relative URL to absolute URL")); CFStringRef cfStrPath = CFURLCopyFileSystemPath(absoluteURL,kDefaultPathStyle); CFRelease(absoluteURL); - return wxCFStringRef(cfStrPath).AsString(wxLocale::GetSystemEncoding()); + return wxCFStringRef::AsStringWithNormalizationFormC(cfStrPath); } wxString wxStandardPathsCF::GetFromFunc(wxCFURLRef (*func)(wxCFBundleRef)) const -- 2.45.2