diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index c463a2dbfd..1a1adb0a3a 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -32,6 +32,7 @@ #include #include #include +#include ///! The following environment variables will never be migrated from a previous version @@ -430,11 +431,25 @@ bool COMMON_SETTINGS::migrateSchema2to3() std::vector legacyPaths; readLegacy3DResolverCfg( cfgpath.GetFullPath(), legacyPaths ); + // env variables have a limited allowed character set for names + wxRegEx nonValidCharsRegex( "[^A-Z0-9_]+", wxRE_ADVANCED ); + for( const LEGACY_3D_SEARCH_PATH& path : legacyPaths ) { - const wxString& key = path.m_Alias; + wxString key = path.m_Alias; const wxString& val = path.m_Pathvar; + // The 3d alias config didnt use the same naming restrictions as real env variables + // We need to sanitize them + + // upper case only + key.MakeUpper(); + // logically swap - with _ + key.Replace( wxS( "-" ), wxS( "_" ) ); + + // remove any other chars + nonValidCharsRegex.Replace( &key, wxEmptyString ); + if( !m_Env.vars.count( key ) ) { wxLogTrace( traceEnvVars, "COMMON_SETTINGS: Loaded new var: %s = %s", key, val );