From 71e946e3a51b662d8782ed6945f891b602c1bff7 Mon Sep 17 00:00:00 2001 From: Steven Cohn Date: Tue, 30 Apr 2024 19:48:01 -0400 Subject: [PATCH] Fix FavoritesProvider.ConfirmByLocations --- OneMore/Commands/Favorites/FavoritesProvider.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OneMore/Commands/Favorites/FavoritesProvider.cs b/OneMore/Commands/Favorites/FavoritesProvider.cs index b4dc5310d9..b2cd64d924 100644 --- a/OneMore/Commands/Favorites/FavoritesProvider.cs +++ b/OneMore/Commands/Favorites/FavoritesProvider.cs @@ -294,6 +294,15 @@ private async Task ConfirmByLocation(Favorite favorite) books ??= await one.GetNotebooks(); var parts = favorite.Location.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length < 3) + { + // corrupt screentip attribute in XML? (populates Location) + // must be at least: /notebook/section/title + logger.WriteLine($"invalid favorite location {favorite.Location} [{favorite.Name}]"); + favorite.Status = FavoriteStatus.Suspect; + return false; + } + var notebook = notebooks.Values.FirstOrDefault(n => n.Attribute("name")?.Value == parts[0]); if (notebook == null) {