Skip to content

Commit 9a3fea0

Browse files
committed
Fix: trim whitespace from certain DSN fields (#189)
Trim whitespace from Cloud ID, User and Host field values before submitting these to the driver (WS is likely to be inserted if copy&pasting these values.) Also, rephrase the error message presented to the user in case the Cloud ID is incorrect. (cherry picked from commit c4b36bb) Cherry-pick conflicts: - driver/connect.c - dsneditor/EsOdbcDsnEditor/DSNEditorForm.cs resolved by removing the cloud-id related code from the merge.
1 parent 5c5ca63 commit 9a3fea0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dsneditor/EsOdbcDsnEditor/DSNEditorForm.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,12 @@ private bool RebuildAndValidateDsn()
230230
// Basic Panel
231231
Builder["dsn"] = textName.Text;
232232
Builder["description"] = textDescription.Text;
233-
Builder["uid"] = textUsername.Text;
233+
// https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html#security-api-put-user-path-params :
234+
// "Leading or trailing whitespace is not allowed." -> it is more likely that a user will insert a
235+
// (trailing) white space by mistake than intentionally trying to set it.
236+
Builder["uid"] = textUsername.Text.Trim();
234237
Builder["pwd"] = textPassword.Text;
235-
Builder["server"] = textHostname.Text;
238+
Builder["server"] = textHostname.Text.Trim();
236239
Builder["port"] = numericUpDownPort.Text;
237240

238241
// Security Panel

0 commit comments

Comments
 (0)