Linux/MacOSX: Only load valid XML language files (Language.langid.xml format with langid one of the predefined language identifiers)

This commit is contained in:
Mounir IDRASSI 2024-08-25 09:36:38 +02:00
parent 380ca35c6d
commit d6f0250901
No known key found for this signature in database
GPG Key ID: FC1B00364B3FE937

View File

@ -130,16 +130,25 @@ namespace VeraCrypt
if (wxDir::Exists(languagesFolder.GetName())) { if (wxDir::Exists(languagesFolder.GetName())) {
size_t langCount; 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) { for (size_t i = 0; i < langCount; ++i) {
wxFileName filename(langArray[i]); wxFileName filename(langArray[i]);
wxString langId = filename.GetName().AfterLast('.');
// 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]; wxString langNative = langEntries[langId];
if (!langNative.empty()) { if (!langNative.empty()) {
LanguageListBox->Append(langNative); LanguageListBox->Append(langNative);
} }
} }
} }
}
#endif #endif