lib/lastpass/parser.rb in lastpass-1.6.1 vs lib/lastpass/parser.rb in lastpass-1.7.0
- old
+ new
@@ -5,11 +5,11 @@
class Parser
# OpenSSL constant
RSA_PKCS1_OAEP_PADDING = 4
# Secure note types that contain account-like information
- ALLOWED_SECURE_NOTE_TYPES = {
+ ACCOUNT_LIKE_SECURE_NOTE_TYPES = {
"Server" => true,
"Email Account" => true,
"Database" => true,
"Instant Messenger" => true,
}
@@ -26,13 +26,13 @@
chunks
end
# Parses an account chunk, decrypts and creates an Account object.
- # May return nil when the chunk does not represent an account.
- # All secure notes are ACCTs but not all of them strore account
- # information.
+ # Returns either an Account or a Note object, in case of a generic
+ # note that doesn't represent an account. All secure notes are ACCTs
+ # but not all of them store account information.
#
# TODO: Make a test case that covers secure note account
def self.parse_ACCT chunk, encryption_key
StringIO.open chunk.payload do |io|
id = read_item io
@@ -47,19 +47,19 @@
secure_note = read_item io
# Parse secure note
if secure_note == "1"
parsed = parse_secure_note_server notes
- if !ALLOWED_SECURE_NOTE_TYPES.key? parsed[:type]
- return nil
+ if !ACCOUNT_LIKE_SECURE_NOTE_TYPES.key? parsed[:type]
+ return Note.new id, name, notes, group
end
url = parsed[:url] if parsed.key? :url
username = parsed[:username] if parsed.key? :username
password = parsed[:password] if parsed.key? :password
end
- Account.new id, name, username, password, url, group
+ Account.new id, name, username, password, url, notes, group
end
end
# TODO: Fake some data and make a test
def self.parse_SHAR chunk, encryption_key, rsa_key