From f60059c9837b591622c1a7edf51347f866598d3b Mon Sep 17 00:00:00 2001
From: mw781 <mw781@bbb-test.srcf.net>
Date: Wed, 17 Jun 2020 11:13:07 +0100
Subject: [PATCH] Ensure that files are handled safely 2

---
 record-and-playback/core/lib/recordandplayback.rb           | 2 +-
 .../presentation/scripts/process/presentation.rb            | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/record-and-playback/core/lib/recordandplayback.rb b/record-and-playback/core/lib/recordandplayback.rb
index 573372d657..77a4cfcf73 100755
--- a/record-and-playback/core/lib/recordandplayback.rb
+++ b/record-and-playback/core/lib/recordandplayback.rb
@@ -201,7 +201,7 @@ module BigBlueButton
 
   def self.add_tag_to_xml(xml_filename, parent_xpath, tag, content)
     if File.exist? xml_filename
-      doc = Nokogiri::XML(File.open(xml_filename)) {|x| x.noblanks}
+      doc = Nokogiri::XML(File.read(xml_filename)) {|x| x.noblanks}
 
       node = doc.at_xpath("#{parent_xpath}/#{tag}")
       node.remove if not node.nil?
diff --git a/record-and-playback/presentation/scripts/process/presentation.rb b/record-and-playback/presentation/scripts/process/presentation.rb
index d7d594eb83..f74075080f 100755
--- a/record-and-playback/presentation/scripts/process/presentation.rb
+++ b/record-and-playback/presentation/scripts/process/presentation.rb
@@ -89,7 +89,7 @@ if not FileTest.directory?(target_dir)
     FileUtils.mkdir_p processed_pres_dir
 
     # Get the real-time start and end timestamp
-    @doc = Nokogiri::XML(File.open("#{target_dir}/events.xml"))
+    @doc = Nokogiri::XML(File.read("#{target_dir}/events.xml"))
 
     meeting_start = @doc.xpath("//event")[0][:timestamp]
     meeting_end = @doc.xpath("//event").last()[:timestamp]
@@ -101,7 +101,7 @@ if not FileTest.directory?(target_dir)
 
     # Add start_time, end_time and meta to metadata.xml
     ## Load metadata.xml
-    metadata = Nokogiri::XML(File.open("#{target_dir}/metadata.xml"))
+    metadata = Nokogiri::XML(File.read("#{target_dir}/metadata.xml"))
     ## Add start_time and end_time
     recording = metadata.root
     ### Date Format for recordings: Thu Mar 04 14:05:56 UTC 2010
@@ -243,7 +243,7 @@ if not FileTest.directory?(target_dir)
 
     # Update state in metadata.xml
     ## Load metadata.xml
-    metadata = Nokogiri::XML(File.open("#{target_dir}/metadata.xml"))
+    metadata = Nokogiri::XML(File.read("#{target_dir}/metadata.xml"))
     ## Update status
     recording = metadata.root
     state = recording.at_xpath("state")
-- 
GitLab