From fdc8c78f1fbb04d91c0f984f5f289fd45ee9a747 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 03:05:28 +0000 Subject: [PATCH] Fix: Handle malformed localized format strings in search header --- src/Files.App/ViewModels/ShellViewModel.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index e5bd26e0a617..ff1c4bba0d87 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -2736,9 +2736,25 @@ public async Task SearchAsync(FolderSearch search) await ApplyFilesAndFoldersChangesAsync(); EmptyTextType = EmptyTextType.None; - SearchHeaderTitle = !string.IsNullOrEmpty(search.Query) - ? string.Format(Strings.SearchResultsFor.GetLocalizedResource(), search.Query) - : string.Empty; + if (!string.IsNullOrEmpty(search.Query)) + { + try + { + // Try to format the localized string with the search query + SearchHeaderTitle = string.Format(Strings.SearchResultsFor.GetLocalizedResource(), search.Query); + } + catch (FormatException ex) + { + // Handle malformed localized format strings (e.g., incorrect placeholders in translation) + // Fallback to a safe default format + App.Logger.LogWarning(ex, "Malformed localized format string for SearchResultsFor. Using fallback format."); + SearchHeaderTitle = $"Search results for \"{search.Query}\""; + } + } + else + { + SearchHeaderTitle = string.Empty; + } if (SearchIconBitmapImage is null) SearchIconBitmapImage ??= await UIHelpers.GetSearchIconResource();