rubeepass 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubeepass.rb +34 -19
- data/lib/rubeepass/entry.rb +20 -10
- data/lib/rubeepass/group.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1244eae333d927767643b37d6d6612800fc12a5d
|
4
|
+
data.tar.gz: 3818c6ae675fa05c04df6d62466809b02eccac27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba9bb74e5da41f1aa2c49ac4672a7c23e459cfe31cb2ef9b1bd29e8d0fc2b8ebb32f4bf15eaf03588016768e4cd85d9b5b56d1db4db8ea4ac785d97060f697f
|
7
|
+
data.tar.gz: 9bfd779dcf88b6a38358162aeb01762e6a9144a3db92771d562a5b94795a44385aa57f1b92f77ce84707df9f09be8c755baa4fc268a6c20ea9aa7e6792fbe196
|
data/lib/rubeepass.rb
CHANGED
@@ -311,19 +311,16 @@ class RubeePass
|
|
311
311
|
end
|
312
312
|
private :parse_gzip
|
313
313
|
|
314
|
+
# Horrible attempt at parsing xml. Someday I might use a library
|
314
315
|
def parse_xml
|
315
|
-
curr = Group.new(
|
316
|
-
{
|
317
|
-
"Keepass" => self,
|
318
|
-
"Name" => "/"
|
319
|
-
}
|
320
|
-
)
|
316
|
+
curr = Group.new({"Keepass" => self, "Name" => "/"})
|
321
317
|
entry_params = Hash.new
|
322
318
|
group_params = Hash.new
|
323
319
|
ignore = true
|
320
|
+
inside_value = false
|
324
321
|
status = nil
|
325
322
|
|
326
|
-
@xml.each_line do |line|
|
323
|
+
@xml.gsub("<", "\n<").each_line do |line|
|
327
324
|
line.strip!
|
328
325
|
|
329
326
|
case line
|
@@ -338,20 +335,37 @@ class RubeePass
|
|
338
335
|
next
|
339
336
|
when "</Root>"
|
340
337
|
break
|
338
|
+
when %r{^.*</Value>}
|
339
|
+
line.gsub!(%r{</Value>$}, "")
|
340
|
+
entry_params[status] += line if (line && !line.empty?)
|
341
|
+
if (line && !line.empty?)
|
342
|
+
entry_params[status] += "\n#{line}"
|
343
|
+
end
|
344
|
+
|
345
|
+
status = nil
|
346
|
+
inside_value = false
|
347
|
+
next
|
348
|
+
when ""
|
349
|
+
next if (!inside_value)
|
341
350
|
end
|
342
351
|
|
343
352
|
line = CGI::unescapeHTML(line)
|
344
353
|
line = URI::unescape(line)
|
345
354
|
|
355
|
+
# Handle values with newlines
|
356
|
+
if (inside_value && !ignore)
|
357
|
+
entry_params[status] += "\n#{line}"
|
358
|
+
next
|
359
|
+
end
|
360
|
+
|
346
361
|
# Always handle protected data
|
347
362
|
case line
|
348
|
-
when %r{
|
349
|
-
line.gsub!(%r{
|
363
|
+
when %r{^<Value Protected="True">.+}
|
364
|
+
line.gsub!(%r{^<Value Protected="True">}, "")
|
350
365
|
if (ignore)
|
351
366
|
handle_protected(line)
|
352
367
|
else
|
353
368
|
entry_params[status] = handle_protected(line)
|
354
|
-
status = nil
|
355
369
|
end
|
356
370
|
next
|
357
371
|
else
|
@@ -369,26 +383,27 @@ class RubeePass
|
|
369
383
|
when "</Group>"
|
370
384
|
curr = curr.group
|
371
385
|
break if (curr.nil?)
|
372
|
-
when %r{
|
373
|
-
status = line.gsub(%r{^<Key
|
374
|
-
when %r{
|
375
|
-
line.gsub!(%r{^<Name
|
386
|
+
when %r{^<Key>.+}
|
387
|
+
status = line.gsub(%r{^<Key>}, "")
|
388
|
+
when %r{^<Name>.+}
|
389
|
+
line.gsub!(%r{^<Name>}, "")
|
376
390
|
group_params["Name"] = line
|
377
391
|
|
378
392
|
group = Group.new(group_params)
|
379
393
|
curr.groups[group.name] = group
|
380
394
|
curr = group
|
381
|
-
when %r{
|
382
|
-
uuid = line.gsub(%r{^<UUID
|
395
|
+
when %r{^<UUID>.+}
|
396
|
+
uuid = line.gsub(%r{^<UUID>}, "")
|
383
397
|
if (group_params["UUID"].nil?)
|
384
398
|
group_params["UUID"] = uuid
|
385
399
|
else
|
386
400
|
entry_params["UUID"] = uuid
|
387
401
|
end
|
388
|
-
when %r{
|
389
|
-
line.gsub!(%r{
|
402
|
+
when %r{^<Value>.*}
|
403
|
+
line.gsub!(%r{<Value>}, "")
|
404
|
+
line = "" if (line.nil?)
|
390
405
|
entry_params[status] = line
|
391
|
-
|
406
|
+
inside_value = true
|
392
407
|
end
|
393
408
|
end
|
394
409
|
|
data/lib/rubeepass/entry.rb
CHANGED
@@ -20,23 +20,33 @@ class RubeePass::Entry
|
|
20
20
|
return (self.title.downcase <=> other.title.downcase)
|
21
21
|
end
|
22
22
|
|
23
|
-
def details(level = 0)
|
23
|
+
def details(level = 0, show_passwd = false)
|
24
24
|
lvl = Array.new(level, " ").join
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
ret = Array.new
|
27
|
+
ret.push("#{lvl}Title : #{@title}".green)
|
28
|
+
# ret.push("#{lvl}UUID : #{@uuid}")
|
29
|
+
ret.push("#{lvl}Username : #{@username}")
|
30
|
+
ret.push("#{lvl}Password : #{password}".red) if (show_passwd)
|
31
|
+
ret.push("#{lvl}Url : #{@url}")
|
32
|
+
|
33
|
+
first = true
|
34
|
+
@notes.each_line do |line|
|
35
|
+
if (first)
|
36
|
+
ret.push("#{lvl}Notes : #{line.strip}")
|
37
|
+
first = false
|
38
|
+
else
|
39
|
+
ret.push("#{lvl} #{line.strip}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
return ret.join("\n")
|
34
44
|
end
|
35
45
|
|
36
46
|
def initialize(params)
|
37
47
|
@group = params.fetch("Group", nil)
|
38
48
|
@keepass = params.fetch("Keepass", nil)
|
39
|
-
@
|
49
|
+
@notes = params.fetch("Notes", "")
|
40
50
|
@password = params.fetch("Password", "")
|
41
51
|
@title = params.fetch("Title", "")
|
42
52
|
@url = params.fetch("URL", "")
|
data/lib/rubeepass/group.rb
CHANGED
@@ -19,7 +19,7 @@ class RubeePass::Group
|
|
19
19
|
return (self.name.downcase <=> other.name.downcase)
|
20
20
|
end
|
21
21
|
|
22
|
-
def details(level = 0)
|
22
|
+
def details(level = 0, show_passwd = false)
|
23
23
|
out = Array.new
|
24
24
|
lvl = Array.new(level, " ").join
|
25
25
|
|
@@ -31,11 +31,11 @@ class RubeePass::Group
|
|
31
31
|
end
|
32
32
|
|
33
33
|
@groups.values.each do |group|
|
34
|
-
out.push(group.details(level + 1))
|
34
|
+
out.push(group.details(level + 1, show_passwd))
|
35
35
|
end
|
36
36
|
|
37
37
|
@entries.values.each do |entry|
|
38
|
-
out.push(entry.details(level + 1))
|
38
|
+
out.push(entry.details(level + 1, show_passwd))
|
39
39
|
end
|
40
40
|
|
41
41
|
return out.join("\n")
|