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