From 8bf64d26bc12f30c7b430b5d36176a56f1bff1c8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 13 Nov 2012 20:22:39 +0100 Subject: [PATCH] Don't expand environment vars when reading .mmg files Fixes #795. --- ChangeLog | 6 ++++++ src/mmg/mmg.cpp | 1 + src/mmg/mmg_dialog.cpp | 26 ++++++++++++++------------ src/mmg/tabs/input.cpp | 8 ++++---- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d4f43d4f..b43c2cd79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-11-13 Moritz Bunkus + + * mmg: bug fix: Fixed reading file names containing a '%' from a + .mmg settings file (both normally saved files and the job queue + files). Fixes #795. + 2012-10-08 Moritz Bunkus * mkvmerge: enhancement: Dirac video code: Added four more diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp index d38214070..c6c1765b6 100644 --- a/src/mmg/mmg.cpp +++ b/src/mmg/mmg.cpp @@ -178,6 +178,7 @@ mmg_app::OnInit() { #else cfg = new wxFileConfig(wxT("mkvmergeGUI"), wxEmptyString, get_config_file_name()); #endif + cfg->SetExpandEnvVars(false); wxConfigBase::Set(cfg); init_ui_locale(); diff --git a/src/mmg/mmg_dialog.cpp b/src/mmg/mmg_dialog.cpp index 0b3b14f8d..f2e0fec78 100644 --- a/src/mmg/mmg_dialog.cpp +++ b/src/mmg/mmg_dialog.cpp @@ -380,6 +380,8 @@ mmg_dialog::on_file_new(wxCommandEvent &evt) { tmp_name.Printf(wxT("%stempsettings-%d.mmg"), get_temp_dir().c_str(), (int)wxGetProcessId()); wxFileConfig cfg(wxT("mkvmerge GUI"), wxT("Moritz Bunkus"), tmp_name); + cfg.SetExpandEnvVars(false); + tc_output->SetValue(wxEmptyString); input_page->load(&cfg, MMG_CONFIG_FILE_VERSION_MAX); @@ -415,6 +417,8 @@ mmg_dialog::load(wxString file_name, int version; wxFileConfig cfg(wxT("mkvmerge GUI"), wxT("Moritz Bunkus"), file_name); + cfg.SetExpandEnvVars(false); + cfg.SetPath(wxT("/mkvmergeGUI")); if (!cfg.Read(wxT("file_version"), &version) || (1 > version) || (MMG_CONFIG_FILE_VERSION_MAX < version)) { if (used_for_jobs) @@ -454,20 +458,18 @@ mmg_dialog::on_file_save(wxCommandEvent &) { void mmg_dialog::save(wxString file_name, bool used_for_jobs) { - wxFileConfig *cfg; + wxFileConfig cfg{wxT("mkvmerge GUI"), wxT("Moritz Bunkus"), file_name}; + cfg.SetExpandEnvVars(false); - cfg = new wxFileConfig(wxT("mkvmerge GUI"), wxT("Moritz Bunkus"), file_name); - cfg->SetPath(wxT("/mkvmergeGUI")); - cfg->Write(wxT("file_version"), MMG_CONFIG_FILE_VERSION_MAX); - cfg->Write(wxT("gui_version"), wxT(VERSION)); - cfg->Write(wxT("output_file_name"), tc_output->GetValue()); - cfg->Write(wxT("cli_options"), cli_options); + cfg.SetPath(wxT("/mkvmergeGUI")); + cfg.Write(wxT("file_version"), MMG_CONFIG_FILE_VERSION_MAX); + cfg.Write(wxT("gui_version"), wxT(VERSION)); + cfg.Write(wxT("output_file_name"), tc_output->GetValue()); + cfg.Write(wxT("cli_options"), cli_options); - input_page->save(cfg); - attachments_page->save(cfg); - global_page->save(cfg); - - delete cfg; + input_page->save(&cfg); + attachments_page->save(&cfg); + global_page->save(&cfg); if (!used_for_jobs) { set_status_bar(Z("Configuration saved.")); diff --git a/src/mmg/tabs/input.cpp b/src/mmg/tabs/input.cpp index 46829ca8d..01793b82e 100644 --- a/src/mmg/tabs/input.cpp +++ b/src/mmg/tabs/input.cpp @@ -634,7 +634,8 @@ tab_input::insert_file_in_controls(mmg_file_cptr file, } } - lb_input_files->Insert(wxString::Format(wxT("%s%s (%s)"), append ? wxT("++> ") : wxEmptyString, file->file_name.AfterLast(wxT(PSEP)).c_str(), file->file_name.BeforeLast(wxT(PSEP)).c_str()), new_file_pos); + wxFileName fn{file->file_name}; + lb_input_files->Insert(wxString::Format(wxT("%s%s (%s)"), append ? wxT("++> ") : wxEmptyString, fn.GetFullName().c_str(), fn.GetPath().c_str()), new_file_pos); files.insert(files.begin() + new_file_pos, file); @@ -1230,9 +1231,8 @@ tab_input::load(wxConfigBase *cfg, } if (!fi->tracks.empty()) { - s = fi->file_name.BeforeLast(PSEP); - c = fi->file_name.AfterLast(PSEP); - lb_input_files->Append(wxString::Format(wxT("%s%s (%s)"), fi->appending ? wxT("++> ") : wxEmptyString, c.c_str(), s.c_str())); + wxFileName fn{fi->file_name}; + lb_input_files->Append(wxString::Format(wxT("%s%s (%s)"), fi->appending ? wxT("++> ") : wxEmptyString, fn.GetFullName().c_str(), fn.GetPath().c_str())); files.push_back(fi); }