From 864216eaf710aebb28b752cc0b27c1abff3abf3a Mon Sep 17 00:00:00 2001 From: John Kingsbury <57527020+JohnKingsbury@users.noreply.github.com> Date: Fri, 2 Oct 2020 20:00:02 +0100 Subject: [PATCH] Correct URL encoding to allow web searches for FMs containing &s --- AngelLoader/Core.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AngelLoader/Core.cs b/AngelLoader/Core.cs index 0bd79e4e1..bd2462344 100644 --- a/AngelLoader/Core.cs +++ b/AngelLoader/Core.cs @@ -1338,15 +1338,17 @@ internal static void OpenWebSearchUrl(string fmTitle) string url = Config.WebSearchUrl; if (url.IsWhiteSpace() || url.Length > 32766) return; + url = Uri.EscapeUriString(url); + int index = url.IndexOf("$TITLE$", StringComparison.OrdinalIgnoreCase); // Possible exceptions are: // ArgumentNullException (stringToEscape is null) // UriFormatException (The length of stringToEscape exceeds 32766 characters) // Those are both checked for above so we're good. - string finalUrl = Uri.EscapeUriString(index == -1 + string finalUrl = index == -1 ? url - : url.Substring(0, index) + fmTitle + url.Substring(index + "$TITLE$".Length)); + : url.Substring(0, index) + Uri.EscapeDataString(fmTitle) + url.Substring(index + "$TITLE$".Length); try {