Sanitize the variable names in the 3d alias migration
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12683
This commit is contained in:
parent
9b4505c6d2
commit
29bf96f7f0
|
@ -32,6 +32,7 @@
|
|||
#include <trace_helpers.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/regex.h>
|
||||
|
||||
|
||||
///! The following environment variables will never be migrated from a previous version
|
||||
|
@ -430,11 +431,25 @@ bool COMMON_SETTINGS::migrateSchema2to3()
|
|||
std::vector<LEGACY_3D_SEARCH_PATH> 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 );
|
||||
|
|
Loading…
Reference in New Issue