From 735accc1a8fb75afe4a4f2f76118ded5f70a56e2 Mon Sep 17 00:00:00 2001 From: Mykhailo Pylyp Date: Fri, 18 Jun 2021 13:01:40 +0300 Subject: [PATCH] Don't crash if URI can't be parsed (#11788) --- .../SearchHelper/WindowsSearchAPI.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs index a47a2281a0..d831e6a787 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Indexer/SearchHelper/WindowsSearchAPI.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using Microsoft.Search.Interop; +using Wox.Plugin.Logger; namespace Microsoft.Plugin.Indexer.SearchHelper { @@ -49,7 +50,12 @@ namespace Microsoft.Plugin.Indexer.SearchHelper // # is URI syntax for the fragment component, need to be encoded so LocalPath returns complete path // Using OrdinalIgnoreCase since this is internal and used with symbols var string_path = ((string)oleDBResult.FieldData[0]).Replace("#", "%23", StringComparison.OrdinalIgnoreCase); - var uri_path = new Uri(string_path); + + if (!Uri.TryCreate(string_path, UriKind.RelativeOrAbsolute, out Uri uri_path)) + { + Log.Warn($"Failed to parse URI '${string_path}'", typeof(WindowsSearchAPI)); + continue; + } var result = new SearchResult {