diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 7be8a9b864..133804edc6 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -228,15 +228,27 @@ void wxDataFormat::SetId( NativeFormat format ) void wxDataFormat::SetId( const wxString& zId ) { m_type = wxDF_PRIVATE; - m_id = zId; - // in newer macOS version this must conform to a UTI // https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html - if ( zId.Find('.') != wxNOT_FOUND ) - m_format = wxCFStringRef(zId); + // first filter characters + wxString utiString = zId; + wxString::iterator it; + for (it = utiString.begin(); it != utiString.end(); ++it) + { + wxUniChar c = *it; + if ( !( c >= 'A' && c <='Z') && !( c >= 'a' && c <='z') && !( c >= '0' && c <='9') && + c != '.' && c !='-' ) + *it= '-'; + } + + m_id = utiString; + + // make sure it follows a reverse DNS notation + if ( utiString.Find('.') != wxNOT_FOUND ) + m_format = wxCFStringRef(utiString); else - m_format = wxCFStringRef(privateUTIPrefix+zId); + m_format = wxCFStringRef(privateUTIPrefix+utiString); } bool wxDataFormat::operator==(const wxDataFormat& format) const