Fix support for entries <4 lines long in EntryRefresh()

This commit is contained in:
2025-05-31 20:28:01 -04:00
parent c4db7dfd59
commit 346fa35dc8
+10
View File
@@ -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)