Skip to content
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

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

lhardt
Copy link
Contributor

@lhardt lhardt commented Oct 1, 2024

Summary

  • Adding support for whitespace-trailed passwords. This means blocking AKV from Trimming the first line.
  • Adding support for whitespace-trailed values on AKV.

Technical Notes

  • The TrimSpace on ParseAKV only applies to Keys, not Values. So keys must be trimmed, but values are taken as-is.

@@ -260,15 +260,13 @@ func ParseAKV(in []byte) *AKV {
continue
}

line = strings.TrimSpace(line)
Copy link
Contributor Author

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 trimmed anyway.

key, val, found := strings.Cut(line, kvSep)
if !found {
continue
}

key = strings.TrimSpace(key)
val = strings.TrimSpace(val)
Copy link
Contributor Author

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 Trimmed? It would seem arbitrary otherwise.

Do you normally reference GitHub issues on comments?

Copy link
Member

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
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

@lhardt lhardt Oct 6, 2024

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?

Copy link
Member

@dominikschulz dominikschulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dominikschulz dominikschulz merged commit 3c87c1b into gopasspw:master Oct 7, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants