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:
parent
edb7b6b7ae
commit
a60894832c
1 changed files with 7 additions and 7 deletions
14
lib/MPW.rb
14
lib/MPW.rb
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue