diff --git a/AngelLoader/Core.cs b/AngelLoader/Core.cs index 0bd79e4e1..7124329d4 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; - 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 + url = Uri.EscapeUriString(url); + + int index = url.IndexOf("$TITLE$", StringComparison.OrdinalIgnoreCase); + + 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 {