[
https://issues.apache.org/jira/browse/FLINK-40957?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xiqian Yu updated FLINK-40957:
------------------------------
Component/s: Flink CDC
(was: Connectors / MongoDB)
> 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: Flink CDC
> Environment: OS: Windows 11
> Java: OpenJDK 17.0.20.1
> Flink CDC: master branch (3.7-SNAPSHOT)
> Reporter: luana
> Assignee: luana
> Priority: Minor
> Labels: pull-request-available
> Fix For: cdc-3.8.0
>
> 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
(v10.3.26#10030026)