mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-03 15:47:27 -04:00
Fix support for entries <4 lines long in EntryRefresh()
This commit is contained in:
+20
-10
@@ -66,17 +66,27 @@ func EntryRefresh(oldRCWPassphrase, newRCWPassphrase []byte, removeOldDir bool)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// strip trailing whitespace...
|
// strip trailing whitespace...
|
||||||
fieldsMain := decryptedEntry[:4]
|
fieldsLength := len(decryptedEntry)
|
||||||
fieldsNote := back.RemoveTrailingEmptyStrings(decryptedEntry[4:])
|
if fieldsLength < 4 {
|
||||||
// ...from each non-note field
|
fieldsMain := back.RemoveTrailingEmptyStrings(decryptedEntry)
|
||||||
for i, line := range fieldsMain {
|
// ...from each non-note field
|
||||||
fieldsMain[i] = strings.TrimRight(line, " \t\r\n")
|
for i, line := range fieldsMain {
|
||||||
}
|
fieldsMain[i] = strings.TrimRight(line, " \t\r\n")
|
||||||
// ...and from each note line (preserve Markdown formatting)
|
}
|
||||||
ClampTrailingWhitespace(fieldsNote)
|
decryptedEntry = fieldsMain
|
||||||
|
} else {
|
||||||
|
fieldsMain := decryptedEntry[:4]
|
||||||
|
fieldsNote := back.RemoveTrailingEmptyStrings(decryptedEntry[4:])
|
||||||
|
// ...from each non-note field
|
||||||
|
for i, line := range fieldsMain {
|
||||||
|
fieldsMain[i] = strings.TrimRight(line, " \t\r\n")
|
||||||
|
}
|
||||||
|
// ...and from each note line (preserve Markdown formatting)
|
||||||
|
ClampTrailingWhitespace(fieldsNote)
|
||||||
|
|
||||||
// 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