Skip to content

Commit

Permalink
Correct URL encoding to allow web searches for FMs containing &s
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnKingsbury committed Oct 2, 2020
1 parent 35414db commit 864216e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions AngelLoader/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 864216e

Please sign in to comment.