luana created FLINK-40957:
-----------------------------

             Summary: MongoDB CDC encodes spaces as '+' instead of '%20' in 
credentials
                 Key: FLINK-40957
                 URL: https://issues.apache.org/jira/browse/FLINK-40957
             Project: Flink
          Issue Type: Bug
          Components: Connectors / MongoDB
         Environment: OS: Windows 11
Java: OpenJDK 17.0.20.1
Flink CDC: master branch (3.7-SNAPSHOT)
            Reporter: luana
         Attachments: Screenshot 2026-10-08 124003.png

MongoDBEnvelope.encodeValue currently uses:
 
URLEncoder.encode(value, StandardCharsets.UTF_8.name())
 
URLEncoder follows application/x-www-form-urlencoded semantics and encodes 
spaces as '+'.
 
For MongoDB connection strings, spaces should be percent-encoded as '%20'.
 
Example:
 
Input:
my pass
 
Current:
my+pass
 
Expected:
my%20pass
 
This can cause authentication failures when usernames or passwords contain 
spaces.
 
I reproduced the issue with a unit test:
 
assertEquals(
    "my%20pass",
    MongoDBEnvelope.encodeValue("my pass"));
 
The test fails with the current implementation and passes after replacing '+' 
with '%20':
 
URLEncoder.encode(value, StandardCharsets.UTF_8.name())
    .replace("+", "%20");
 
Reference:
https://stackoverflow.com/questions/4737841/urlencoder-not-able-to-translate-space-character



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to