Make cookie merging more robust (#669)

This commit is contained in:
kaso17
2016-11-10 08:37:52 +01:00
committed by GitHub
parent e7918bddbc
commit 7cfdaf4b41

View File

@@ -186,7 +186,7 @@ namespace Jackett.Indexers
private String ResolveCookies(String incomingCookies = "") private String ResolveCookies(String incomingCookies = "")
{ {
var redirRequestCookies = (CookieHeader != null && CookieHeader != "" ? CookieHeader + " " : "") + incomingCookies; var redirRequestCookies = (CookieHeader != null && CookieHeader != "" ? CookieHeader + " " : "") + incomingCookies;
System.Text.RegularExpressions.Regex expression = new System.Text.RegularExpressions.Regex(@"([^\s]+)=([^=]+)(?:\s|$)"); System.Text.RegularExpressions.Regex expression = new System.Text.RegularExpressions.Regex(@"([^\\,;\s]+)=([^=\\,;\s]+)");
Dictionary<string, string> cookieDIctionary = new Dictionary<string, string>(); Dictionary<string, string> cookieDIctionary = new Dictionary<string, string>();
var matches = expression.Match(redirRequestCookies); var matches = expression.Match(redirRequestCookies);
while (matches.Success) while (matches.Success)
@@ -194,7 +194,7 @@ namespace Jackett.Indexers
if (matches.Groups.Count > 2) cookieDIctionary[matches.Groups[1].Value] = matches.Groups[2].Value; if (matches.Groups.Count > 2) cookieDIctionary[matches.Groups[1].Value] = matches.Groups[2].Value;
matches = matches.NextMatch(); matches = matches.NextMatch();
} }
return string.Join(" ", cookieDIctionary.Select(kv => kv.Key.ToString() + "=" + kv.Value.ToString()).ToArray()); return string.Join("; ", cookieDIctionary.Select(kv => kv.Key.ToString() + "=" + kv.Value.ToString()).ToArray());
} }