Skip to content

Commit

Permalink
Fix FavoritesProvider.ConfirmByLocations
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn committed Apr 30, 2024
1 parent 1a62b10 commit 71e946e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions OneMore/Commands/Favorites/FavoritesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ private async Task<bool> 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)
{
Expand Down

0 comments on commit 71e946e

Please sign in to comment.