Skip to content

Commit c34638c

Browse files
committed
Land rapid7#2777, @wchen-r7's fix for safari_lastsession
2 parents 345e171 + 10e1667 commit c34638c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/post/osx/gather/safari_lastsession.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def get_safari_version
4141
version = ''
4242

4343
f = read_file("/Applications/Safari.app/Contents/version.plist")
44-
xml = REXML::Document.new(f)
45-
return version if xml.root.nil?
44+
xml = REXML::Document.new(f) rescue nil
45+
return version if xml.nil?
4646

4747
xml.elements['plist/dict'].each_element do |e|
4848
if e.text == 'CFBundleShortVersionString'
@@ -76,7 +76,7 @@ def plutil(filename)
7676
#
7777
def get_lastsession
7878
print_status("#{peer} - Looking for LastSession.plist")
79-
plutil("~/Library/Safari/LastSession.plist")
79+
plutil("#{expand_path("~")}/Library/Safari/LastSession.plist")
8080
end
8181

8282

@@ -88,8 +88,8 @@ def get_lastsession
8888
def get_sessions(lastsession)
8989
session_dict = nil
9090

91-
xml = REXML::Document.new(lastsession)
92-
return nil if xml.root.nil?
91+
xml = REXML::Document.new(lastsession) rescue nil
92+
return nil if xml.nil?
9393

9494
xml.elements['plist'].each_element do |e|
9595
found = false

0 commit comments

Comments
 (0)