From 564f234e2c0d19d0708d92281843f9c3f492ca21 Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Thu, 17 Feb 2022 10:18:16 +0100 Subject: [PATCH 1/3] do not strip surrounding white space in CDATA XML elements (bsc#1195910) --- library/xml/src/modules/XML.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/library/xml/src/modules/XML.rb b/library/xml/src/modules/XML.rb index f862d4d0e..93618add8 100644 --- a/library/xml/src/modules/XML.rb +++ b/library/xml/src/modules/XML.rb @@ -248,19 +248,12 @@ def parse_node(node, result) # we need just direct text under node. Can be splitted with another elements # but remove whitespace only text # - # Do NOT strip trailing white space in CDATA blocks. Maybe people put - # it intentionally there (bsc#1195910). - # - # But strip leading white space. This is useful to avoid problems with - # unexpected empty lines at the start of scripts. - # - # An example for this is the script section in this AutoYaST file from - # the official AutoYaST docs: - # https://doc.opensuse.org/projects/autoyast/#Profile-Format + # Do NOT strip surrounding white space in CDATA blocks (bsc#1195910). + # This restores the behavior prior to SLE15-SP3. # # See also #add_element. text_nodes = node.xpath("text()") - text = text_nodes.map { |n| n.cdata? ? n.content.lstrip : n.content.strip }.join + text = text_nodes.map { |n| n.cdata? ? n.content : n.content.strip }.join type = fetch_type(text, children, node) @@ -314,9 +307,9 @@ def add_element(doc, metadata, parent, contents, parent_array: nil) element = Nokogiri::XML::Node.new(key, doc) case value when ::String - # Write CDATA block if string ends with white space. This matches + # Write CDATA block if string has surrounding white space. This matches # the stripping in #parse_node. - if value.match?(/\s\z/) + if value.match?(/\A\s|\s\z/) element.add_child(doc.create_cdata(value)) else element.content = value From 3d7eb0d7350f70b575220783e17b0143430f04d6 Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Thu, 17 Feb 2022 10:27:44 +0100 Subject: [PATCH 2/3] adjust unit tests --- library/xml/test/xml_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/xml/test/xml_test.rb b/library/xml/test/xml_test.rb index 71bdc7f67..4f239d611 100644 --- a/library/xml/test/xml_test.rb +++ b/library/xml/test/xml_test.rb @@ -86,13 +86,13 @@ expect(subject.YCPToXMLString("test", input)).to eq expected end - it "creates no CDATA element if string starts with spaces" do + it "creates CDATA element if string starts with spaces" do input = { "test" => " test", "lest" => "\nlest" } expected = "\n" \ "\n" \ "\n" \ - " \nlest\n" \ - " test\n" \ + " \n" \ + " \n" \ "\n" expect(subject.YCPToXMLString("test", input)).to eq expected @@ -343,13 +343,13 @@ expect(subject.XMLToYCPString(input)).to eq expected end - it "strips spaces at the start of CDATA elements" do + it "preserves spaces at the start of CDATA elements" do input = "\n" \ "\n" \ " \n" \ " \n" \ "\n" - expected = { "test" => "foo", "lest" => "bar" } + expected = { "test" => " foo", "lest" => "\nbar" } expect(subject.XMLToYCPString(input)).to eq expected end From 74b6f7a8bfe39aad105cb8472d7c3028e97cd930 Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Thu, 17 Feb 2022 10:34:08 +0100 Subject: [PATCH 3/3] release 4.3.68 --- package/yast2.changes | 6 ++++++ package/yast2.spec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package/yast2.changes b/package/yast2.changes index 3c53dfd89..33928df08 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Feb 17 09:33:37 UTC 2022 - Steffen Winterfeldt + +- do not strip surrounding white space in CDATA XML elements (bsc#1195910) +- 4.3.68 + ------------------------------------------------------------------- Wed Feb 16 15:41:54 UTC 2022 - Steffen Winterfeldt diff --git a/package/yast2.spec b/package/yast2.spec index 70704b2df..92e6fe039 100644 --- a/package/yast2.spec +++ b/package/yast2.spec @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.3.67 +Version: 4.3.68 Release: 0 Summary: YaST2 Main Package