Skip to content

Commit

Permalink
Merge pull request #877 from yast/xml_exceptions
Browse files Browse the repository at this point in the history
Xml exceptions
  • Loading branch information
jreidinger committed Jul 27, 2020
2 parents c35fa86 + 5242b98 commit ce817af
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jul 27 13:43:29 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

- Handle exceptions when parsing xml file (related to bsc#1170886)
- 4.3.12

-------------------------------------------------------------------
Mon Jul 27 08:14:24 UTC 2020 - Steffen Winterfeldt <snwint@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.3.11
Version: 4.3.12
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand Down
13 changes: 8 additions & 5 deletions src/modules/ImageInstallation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,10 @@ def FillUpImagesDetails
return false
end

read_details = XML.XMLToYCPFile(filename)
if read_details.nil?
Builtins.y2error("Cannot parse imagesets details")
begin
read_details = XML.XMLToYCPFile(filename)
rescue XMLDeserializationError => e
Builtins.y2error("Cannot parse imagesets details. #{e.inspect}")
return false
end

Expand Down Expand Up @@ -820,12 +821,14 @@ def FindImageSet(patterns)
return true
end

image_descr = XML.XMLToYCPFile(filename)
if image_descr.nil?
begin
image_descr = XML.XMLToYCPFile(filename)
rescue RuntimeError => e
@image_installation_available = false
Installation.image_installation = false
Installation.image_only = false
Report.Error(_("Failed to read information about installation images"))
log.error "xml failed to read #{e.inspect}"
return false
end

Expand Down
14 changes: 14 additions & 0 deletions test/image_installation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
ARCHS = ["i386", "x86_64", "ppc"].freeze

describe Yast::ImageInstallation do
subject { described_class }

before do
stub_const("Yast::Packages", double(theSources: [0]))
end
Expand Down Expand Up @@ -70,5 +72,17 @@
end
end
end

it "returns true if no xml is provided" do
allow(Yast::Pkg).to receive(:SourceProvideDigestedFile).and_return(nil)

expect(subject.FindImageSet([])).to eq true
end

it "returns false if xml is not valid" do
allow(Yast::XML).to receive(:XMLToYCPFile).and_raise(Yast::XMLDeserializationError)

expect(subject.FindImageSet([])).to eq false
end
end
end

0 comments on commit ce817af

Please sign in to comment.