Fix bracketed-paste mode messing up password input in client reconnect #48528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix clickhouse-client not accepting copy-pasted password in interactive mode when reconnecting (because of bracketed-paste mode).
Fixes the following scenario:
clickhouse client --host <hostname> --secure --port <port> --user default
Password for user (default):
. Paste it in. It connects::)
.SELECT 1
The problem was "bracketed-paste mode": clickhouse client instructed the terminal to surround copy-pasted text with control sequences (like this:
\x1b[200~thepassword\x1b[201~
), then password input didn't recognize them and got confused.This PR fixes it by enabling the bracketed-paste mode only for the duration of query input, keeping it disabled at all other times. An alternative would be to make the password input recognize and skip the escape sequences (ascii control characters are not allowed in passwords already anyway, so this wouldn't limit the set of usable passwords). I'm not sure which option is better.