Skip to content

Commit 186df67

Browse files
committed
Added additional checks on parsing.
1 parent 7931f70 commit 186df67

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/MongoDB.Driver/Core/Configuration/ConnectionString.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,13 +1043,23 @@ private void ParseOption(string name, string value)
10431043
_minPoolSize = ParseInt32(name, value);
10441044
break;
10451045
case "proxyhost":
1046+
if (!string.IsNullOrEmpty(_proxyHost))
1047+
{
1048+
throw new MongoConfigurationException("Multiple proxyHost options are not allowed.");
1049+
}
1050+
10461051
_proxyHost = value;
10471052
if (_proxyHost.Length == 0)
10481053
{
10491054
throw new MongoConfigurationException("proxyHost cannot be empty.");
10501055
}
10511056
break;
10521057
case "proxyport":
1058+
if (_proxyPort != null)
1059+
{
1060+
throw new MongoConfigurationException("Multiple proxyPort options are not allowed.");
1061+
}
1062+
10531063
var proxyPortValue = ParseInt32(name, value);
10541064
if (proxyPortValue is < 0 or > 65535)
10551065
{
@@ -1058,13 +1068,23 @@ private void ParseOption(string name, string value)
10581068
_proxyPort = proxyPortValue;
10591069
break;
10601070
case "proxyusername":
1071+
if (!string.IsNullOrEmpty(_proxyUsername))
1072+
{
1073+
throw new MongoConfigurationException("Multiple proxyUsername options are not allowed.");
1074+
}
1075+
10611076
_proxyUsername = value;
10621077
if (_proxyUsername.Length == 0)
10631078
{
10641079
throw new MongoConfigurationException("proxyUsername cannot be empty.");
10651080
}
10661081
break;
10671082
case "proxypassword":
1083+
if (!string.IsNullOrEmpty(_proxyPassword))
1084+
{
1085+
throw new MongoConfigurationException("Multiple proxyPassword options are not allowed.");
1086+
}
1087+
10681088
_proxyPassword = value;
10691089
if (_proxyPassword.Length == 0)
10701090
{

0 commit comments

Comments
 (0)