mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-05 16:47:22 -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
|
return err
|
||||||
}
|
}
|
||||||
// strip trailing whitespace...
|
// 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]
|
fieldsMain := decryptedEntry[:4]
|
||||||
fieldsNote := back.RemoveTrailingEmptyStrings(decryptedEntry[4:])
|
fieldsNote := back.RemoveTrailingEmptyStrings(decryptedEntry[4:])
|
||||||
// ...from each non-note field
|
// ...from each non-note field
|
||||||
@@ -77,6 +86,7 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
|
|||||||
|
|
||||||
// re-combine fields
|
// re-combine fields
|
||||||
decryptedEntry = append(fieldsMain, fieldsNote...)
|
decryptedEntry = append(fieldsMain, fieldsNote...)
|
||||||
|
}
|
||||||
|
|
||||||
// re-encrypt the entry with the new passphrase
|
// re-encrypt the entry with the new passphrase
|
||||||
encBytes = wrappers.Encrypt([]byte(strings.Join(decryptedEntry, "\n")), newRCWPassphrase)
|
encBytes = wrappers.Encrypt([]byte(strings.Join(decryptedEntry, "\n")), newRCWPassphrase)
|
||||||
|
|||||||
Reference in New Issue
Block a user