From d6f0250901b70892f121495ffbfbbc413791fd60 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 25 Aug 2024 09:36:38 +0200 Subject: Linux/MacOSX: Only load valid XML language files (Language.langid.xml format with langid one of the predefined language identifiers) --- src/Main/Forms/PreferencesDialog.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/Main/Forms') diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index a610987d..4e7644b6 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -130,13 +130,22 @@ namespace VeraCrypt if (wxDir::Exists(languagesFolder.GetName())) { size_t langCount; - langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, wxEmptyString, wxDIR_FILES); + langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, "*.xml", wxDIR_FILES); for (size_t i = 0; i < langCount; ++i) { wxFileName filename(langArray[i]); - wxString langId = filename.GetName().AfterLast('.'); - wxString langNative = langEntries[langId]; - if (!langNative.empty()) { - LanguageListBox->Append(langNative); + + // Get the name part of the file (without extension) + wxString basename = filename.GetName(); + + // Check if the basename matches the pattern "Language.langId" + if (basename.StartsWith("Language.")) { + wxString langId = basename.AfterFirst('.'); + + // Verify if the language ID exists in langEntries map + wxString langNative = langEntries[langId]; + if (!langNative.empty()) { + LanguageListBox->Append(langNative); + } } } } -- cgit v1.2.3