Force trimming whitespace in env vars

Nothing good can come of leading or trailing whitespace in environment
variables.  They don't resolve correctly and you can't see why
This commit is contained in:
Seth Hillbrand
2025-07-23 17:36:51 -07:00
parent d195e93ebe
commit 8d65217fda
2 changed files with 8 additions and 3 deletions
@@ -252,6 +252,9 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event )
int col = event.GetCol();
wxString text = event.GetString();
text.Trim( true ).Trim( false ); // Trim from both sides
grid->SetCellValue( row, col, text ); // Update the grid with trimmed value
if( text.IsEmpty() )
{
if( grid == m_EnvVars )
+5 -3
View File
@@ -143,6 +143,8 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
wxString value = var.GetValue();
value.Trim( true ).Trim( false ); // Trim from both sides
// Vars that existed in JSON are persisted, but if they were overridden
// externally, we persist the old value (i.e. the one that was loaded from JSON)
if( var.GetDefinedExternally() )
@@ -169,7 +171,7 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
wxS( "COMMON_SETTINGS: Saving env var %s = %s" ),
var.GetKey(), value);
std::string key( var.GetKey().ToUTF8() );
std::string key( var.GetKey().Trim( true ).Trim( false ).ToUTF8() );
ret[ std::move( key ) ] = value;
}
@@ -182,8 +184,8 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
for( const auto& entry : aJson.items() )
{
wxString key = wxString( entry.key().c_str(), wxConvUTF8 );
wxString val = entry.value().get<wxString>();
wxString key = wxString( entry.key().c_str(), wxConvUTF8 ).Trim( true ).Trim( false );
wxString val = entry.value().get<wxString>().Trim( true ).Trim( false );
if( m_Env.vars.count( key ) )
{