Skip to content

Conversation

@MuAlphaOmegaEpsilon
Copy link

@MuAlphaOmegaEpsilon MuAlphaOmegaEpsilon commented Dec 31, 2025

In a pass file, additional key-value pairs are supposed to be stored separated by a single semicolon :.
This is to allow simple command line interoperability, like in the following case:

$ pass tommaso/github
**********
user:MuAlphaOmegaEpsilon
url:https://github.com
otpauth://totp/Github:MuAlphaOmegaEpsilon?secret=********&issuer=GitHub
$ pass tommaso/github | grep user | cut -d : -f 1 --complement
MuAlphaOmegaEpsilon
# Fetch key names only
$ pass tommaso/github | cut -d : -f 1 -s
user
url
otpauth
# Fetch values only (corresponding to key names)
$ pass tommaso/github | cut -d : -f 1 --complement -s
MuAlphaOmegaEpsilon
https://github.com
//totp/Github:MuAlphaOmegaEpsilon?secret=********&issuer=GitHub

The OTP authorization key is already working as intended, as it can be seen from the screenshot below. All additional fields should be recognized with the simpler : separator, instead of the current : one containing a whitespace.
passforios-tommaso-github-screenshot

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

Your reasoning makes sense to me.

Looks like this can be changed without breaking existing password files. However, you need to make sure that splitting only happens on the first colon (subsequent ones might be parts of values).

Comment on lines 74 to 89
var key: String?
var value = ""
if items.count == 1 || (items[0].isEmpty && items[1].isEmpty) {
// No ': ' found, or empty on both sides of ': '.
value = line
// "otpauth" special case
if value.hasPrefix(Constants.OTPAUTH_URL_START) {
key = Constants.OTPAUTH
}
} else {
if !items[0].isEmpty {
key = items[0]
}
value = items[1]
}
return (key, value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This parts needs adaptions as well. otpauth is now already covered by the initial split. We'd also need test cases.

@MuAlphaOmegaEpsilon MuAlphaOmegaEpsilon force-pushed the tweak-additional-fields-separator branch 2 times, most recently from fff40a4 to a610a4f Compare January 4, 2026 18:21
@MuAlphaOmegaEpsilon MuAlphaOmegaEpsilon force-pushed the tweak-additional-fields-separator branch from a610a4f to 849f4f5 Compare January 4, 2026 18:22
@MuAlphaOmegaEpsilon
Copy link
Author

Pushed an update that only splits on the first occurrence of :.
What do you think?

@SimplyDanny
Copy link
Collaborator

Tests are failing. Please check them out.

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.

2 participants