Skip to content

Commit 7a05b03

Browse files
authored
CDRIVER-5580 treat commas in TOKEN_RESOURCE as a client error (#1950)
1 parent 33ffbb3 commit 7a05b03

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/libmongoc/doc/mongoc_uri_t.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Mechanism Properties
133133

134134
The following properties may be specified as key-value pairs for the ``MONGOC_URI_AUTHMECHANISMPROPERTIES`` option.
135135

136-
These properties may only be specified when the corresponding authentication mechanism is also specified.
136+
Invalid or unsupported properties may be reported as a client error when a corresponding authentication mechanism is also specified.
137137

138138
MONGODB-OIDC
139139
^^^^^^^^^^^^
@@ -147,8 +147,8 @@ TOKEN_RESOURCE The URI of the target resource. ``ENVIRONMENT`` must be one of ["
147147

148148
.. warning::
149149

150-
The value of the ``TOKEN_RESOURCE`` property MUST NOT contain the comma character "," when specified as a connection string query option.
151-
Any commas in the value MUST be percent-encoded (as "%2C") to avoid being interpreted as a key-value pair delimiter.
150+
A ``TOKEN_RESOURCE`` property value MUST NOT contain the comma character "," when specified as a connection string query option, even when percent-encoded.
151+
A value containing a comma character may be set using :symbol:`mongoc_uri_set_mechanism_properties()` instead.
152152
However, the value MAY contain the colon character ":", as only the first colon is interpreted as a key-value delimiter.
153153

154154
GSSAPI

src/libmongoc/tests/test-mongoc-connection-uri.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ run_uri_test (const char *uri_string,
115115
if (strstr (uri_string, "CANONICALIZE_HOST_NAME:none") || strstr (uri_string, "CANONICALIZE_HOST_NAME:forward")) {
116116
return;
117117
}
118+
119+
// CDRIVER-5580: commas in TOKEN_RESOURCE are interpreted as a key-value pair delimiter which produces an invalid
120+
// mechanism property that is diagnosed as a client error instead of a warning.
121+
if (strstr (uri_string, "TOKEN_RESOURCE:mongodb://host1%2Chost2")) {
122+
MONGOC_WARNING ("percent-encoded commas in TOKEN_RESOURCE");
123+
return;
124+
}
118125
}
119126

120127
if (uri) {

0 commit comments

Comments
 (0)