Skip to content

Commit

Permalink
Fixing proxy bypass address serialization for legacy .NET drivers
Browse files Browse the repository at this point in the history
The W3C WebDriver Specification states that the list of addresses to
bypass in a proxy configuration should be an array. The legacy OSS dialect
of the protocol specifies it must be a string. This commit fixes the
serialization for the non-spec-compliant case, serializing it as a
semicolon-separated list. Fixes issue #5645.
  • Loading branch information
jimevans committed Mar 20, 2018
1 parent 6103798 commit f454a5c
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions dotnet/src/webdriver/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,22 @@ public void AddBypassAddresses(IEnumerable<string> addressesToAdd)
/// <returns>A dictionary suitable for serializing to the W3C Specification
/// dialect of the wire protocol.</returns>
internal Dictionary<string, object> ToCapability()
{
return this.AsDictionary(true);
}

/// <summary>
/// Returns a dictionary suitable for serializing to the OSS dialect of the
/// wire protocol.
/// </summary>
/// <returns>A dictionary suitable for serializing to the OSS dialect of the
/// wire protocol.</returns>
internal Dictionary<string, object> ToLegacyCapability()
{
return this.AsDictionary(false);
}

private Dictionary<string, object> AsDictionary(bool isSpecCompliant)
{
Dictionary<string, object> serializedDictionary = null;
if (this.proxyKind != ProxyKind.Unspecified)
Expand Down Expand Up @@ -484,19 +500,34 @@ internal Dictionary<string, object> ToCapability()

if (this.noProxyAddresses.Count > 0)
{
List<object> addressList = new List<object>();
foreach (string address in this.noProxyAddresses)
{
addressList.Add(address);
}

serializedDictionary["noProxy"] = addressList;
serializedDictionary["noProxy"] = this.GetNoProxyAddressList(isSpecCompliant);
}
}

return serializedDictionary;
}

private object GetNoProxyAddressList(bool isSpecCompliant)
{
object addresses = null;
if (isSpecCompliant)
{
List<object> addressList = new List<object>();
foreach (string address in this.noProxyAddresses)
{
addressList.Add(address);
}

addresses = addressList;
}
else
{
addresses = this.BypassProxyAddresses;
}

return addresses;
}

private void VerifyProxyTypeCompatilibily(ProxyKind compatibleProxy)
{
if (this.proxyKind != ProxyKind.Unspecified && this.proxyKind != compatibleProxy)
Expand Down

0 comments on commit f454a5c

Please sign in to comment.