mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Fix support for entries <4 lines long in EntryRefresh()
This commit is contained in:
@@ -66,6 +66,15 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
|
||||
return err
|
||||
}
|
||||
// strip trailing whitespace...
|
||||
fieldsLength := len(decryptedEntry)
|
||||
if fieldsLength < 4 {
|
||||
fieldsMain := back.RemoveTrailingEmptyStrings(decryptedEntry)
|
||||
// ...from each non-note field
|
||||
for i, line := range fieldsMain {
|
||||
fieldsMain[i] = strings.TrimRight(line, " \t\r\n")
|
||||
}
|
||||
decryptedEntry = fieldsMain
|
||||
} else {
|
||||
fieldsMain := decryptedEntry[:4]
|
||||
fieldsNote := back.RemoveTrailingEmptyStrings(decryptedEntry[4:])
|
||||
// ...from each non-note field
|
||||
@@ -77,6 +86,7 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
|
||||
|
||||
// re-combine fields
|
||||
decryptedEntry = append(fieldsMain, fieldsNote...)
|
||||
}
|
||||
|
||||
// re-encrypt the entry with the new passphrase
|
||||
encBytes = wrappers.Encrypt([]byte(strings.Join(decryptedEntry, "\n")), newRCWPassphrase)
|
||||
|
||||
Reference in New Issue
Block a user