-
-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENHANCEMENT] Allow for whitespace-trailing passwords (#2873) #2954
Conversation
Signed-off-by: Leo Hardt <[email protected]>
@@ -260,15 +260,13 @@ func ParseAKV(in []byte) *AKV { | |||
continue | |||
} | |||
|
|||
line = strings.TrimSpace(line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The components of the line were going to be trim
med anyway.
key, val, found := strings.Cut(line, kvSep) | ||
if !found { | ||
continue | ||
} | ||
|
||
key = strings.TrimSpace(key) | ||
val = strings.TrimSpace(val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add a more detailed comment of why val wasn't Trim
med? It would seem arbitrary otherwise.
Do you normally reference GitHub issues on comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the dead code and add a reference to the GH Issue, please.
t.Parallel() | ||
// Expected behaviour is KEY: VALUE, with one space. | ||
// Fallback should exist for KEY:VALUE, with no spaces. | ||
mlValue := `foobar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue initially was about passwords surrounded by spaces, no just key-values pairs, no?
How does that work for passwords now? A test would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, I think the issue was about whitespace in passwords.
Being able to handle them in KV pairs is very nice as well, but either we need to change the description of the PR to match the implementation or add support for whitespace in passwords as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had a misunderstanding between KV pairs and the password itself. But it should also be simple to not Trim
the password. But I also see no harm in leaving values trimmed as well. Do you mind if I do both on the same PR?
Signed-off-by: Leo Hardt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Summary
AKV
fromTrim
ming the first line.Technical Notes
TrimSpace
onParseAKV
only applies to Keys, not Values. So keys must be trimmed, but values are taken as-is.