1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-03-20 21:34:35 +00:00

fix bug when you add a password with special char (,;"#)

This commit is contained in:
nishiki 2013-09-19 22:18:30 +02:00
parent edb7b6b7ae
commit a60894832c

View file

@ -99,7 +99,7 @@ class MPW
id = 0 id = 0
data_decrypt.lines do |line| data_decrypt.lines do |line|
@data[id] = line.parse_csv({:col_sep => ';'}).unshift(id) @data[id] = line.parse_csv.unshift(id)
id += 1; id += 1;
end end
end end
@ -125,7 +125,7 @@ class MPW
data_to_encrypt = '' data_to_encrypt = ''
@data.each do |row| @data.each do |row|
row.shift row.shift
data_to_encrypt << "#{row.join(';')}\n" data_to_encrypt << row.to_csv
end end
crypto.encrypt(data_to_encrypt, :recipients => @key, :output => file_gpg) crypto.encrypt(data_to_encrypt, :recipients => @key, :output => file_gpg)
@ -284,7 +284,7 @@ class MPW
File.open(file, 'w+') do |file| File.open(file, 'w+') do |file|
@data.each do |row| @data.each do |row|
row.delete_at(ID) row.delete_at(ID)
file << "#{row.join(';')}\n" file << row.to_csv
end end
end end
@ -302,11 +302,11 @@ class MPW
begin begin
data_new = IO.read(file) data_new = IO.read(file)
data_new.lines do |line| data_new.lines do |line|
if not line =~ /(.*;){6}/ if not line =~ /(.*,){6}/
@error_msg = "Can't import, the file is bad format!" @error_msg = "Can't import, the file is bad format!"
return false return false
else else
row = line.parse_csv({:col_sep => ';'}).unshift(0) row = line.parse_csv.unshift(0)
if not add(row[NAME], row[GROUP], row[SERVER], row[PROTOCOL], row[LOGIN], row[PASSWORD], row[PORT], row[COMMENT]) if not add(row[NAME], row[GROUP], row[SERVER], row[PROTOCOL], row[LOGIN], row[PASSWORD], row[PORT], row[COMMENT])
return false return false
end end
@ -330,11 +330,11 @@ class MPW
data = IO.read(file) data = IO.read(file)
data.lines do |line| data.lines do |line|
if not line =~ /(.*;){6}/ if not line =~ /(.*,){6}/
@error_msg = "Can't import, the file is bad format!" @error_msg = "Can't import, the file is bad format!"
return false return false
else else
result.push(line.parse_csv({:col_sep => ';'}).unshift(id)) result.push(line.parse_csv.unshift(id))
end end
id += 1 id += 1