@@ -91,7 +91,12 @@ func (p Pass) Add(creds *credentials.Credentials) error {
91
91
92
92
encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
93
93
94
- _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
94
+ username := creds .Username
95
+ if strings .Contains (username , "/" ) {
96
+ username = base64 .URLEncoding .EncodeToString ([]byte (creds .Username ))
97
+ }
98
+
99
+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , username ))
95
100
return err
96
101
}
97
102
@@ -164,8 +169,13 @@ func (p Pass) Get(serverURL string) (string, string, error) {
164
169
}
165
170
166
171
actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
172
+ username := actual
173
+ decodedUsername , err := base64 .URLEncoding .DecodeString (actual )
174
+ if err == nil {
175
+ username = string (decodedUsername )
176
+ }
167
177
secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
168
- return actual , secret , err
178
+ return username , secret , err
169
179
}
170
180
171
181
// List returns the stored URLs and corresponding usernames for a given credentials label
@@ -197,6 +207,10 @@ func (p Pass) List() (map[string]string, error) {
197
207
}
198
208
199
209
resp [string (serverURL )] = strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
210
+ decodedUsername , err := base64 .URLEncoding .DecodeString (strings .TrimSuffix (usernames [0 ].Name (), ".gpg" ))
211
+ if err == nil {
212
+ resp [string (serverURL )] = string (decodedUsername )
213
+ }
200
214
}
201
215
202
216
return resp , nil
0 commit comments