This bug has been found during testing bug 19289. In some conditions C4::Biblio::TransformHtmlToXml will generate a malformed XML structure. The last </datafield> can be duplicated. For instance, if a call like: my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values ); with the last value of @field_values is empty, it will return: <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <datafield2 tag="020" ind1=" " ind2=" "> <subfield code="a">l</subfield> </datafield> <datafield1 tag="100" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="245" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="250" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="260" ind1=" " ind2=" "> <subfield code="b">k</subfield> <subfield code="c">k</subfield> </datafield> </datafield> </record> </collection> Which will result later in the following error: :23: parser error : Opening and ending tag mismatch: record line 6 and datafield </datafield> ^ :24: parser error : Opening and ending tag mismatch: collection line 2 and record </record> ^ :25: parser error : Extra content at the end of the document </collection>
Created attachment 73801 [details] [review] Bug 20540: Fix TransformHtmlToXml if last tag is empty This bug has been found during testing bug 19289. In some conditions C4::Biblio::TransformHtmlToXml will generate a malformed XML structure. The last </datafield> can be duplicated. For instance, if a call like: my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values ); with the last value of @field_values is empty, it will return: <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <datafield2 tag="020" ind1=" " ind2=" "> <subfield code="a">l</subfield> </datafield> <datafield1 tag="100" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="245" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="250" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="260" ind1=" " ind2=" "> <subfield code="b">k</subfield> <subfield code="c">k</subfield> </datafield> </datafield> </record> </collection> Which will result later in the following error: :23: parser error : Opening and ending tag mismatch: record line 6 and datafield </datafield> ^ :24: parser error : Opening and ending tag mismatch: collection line 2 and record </record> ^ :25: parser error : Extra content at the end of the document </collection> Test plan: You can test it along with bug 19289 and confirm that it fixes the problem raised on bug 19289 comment 30
Created attachment 73824 [details] [review] Bug 20540: Fix TransformHtmlToXml if last tag is empty This bug has been found during testing bug 19289. In some conditions C4::Biblio::TransformHtmlToXml will generate a malformed XML structure. The last </datafield> can be duplicated. For instance, if a call like: my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values ); with the last value of @field_values is empty, it will return: <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <datafield2 tag="020" ind1=" " ind2=" "> <subfield code="a">l</subfield> </datafield> <datafield1 tag="100" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="245" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="250" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="260" ind1=" " ind2=" "> <subfield code="b">k</subfield> <subfield code="c">k</subfield> </datafield> </datafield> </record> </collection> Which will result later in the following error: :23: parser error : Opening and ending tag mismatch: record line 6 and datafield </datafield> ^ :24: parser error : Opening and ending tag mismatch: collection line 2 and record </record> ^ :25: parser error : Extra content at the end of the document </collection> Test plan: You can test it along with bug 19289 and confirm that it fixes the problem raised on bug 19289 comment 30
Created attachment 73825 [details] [review] Bug 20540: (follow-up) Remove debug line
Created attachment 73914 [details] [review] Bug 20540: Fix TransformHtmlToXml if last tag is empty This bug has been found during testing bug 19289. In some conditions C4::Biblio::TransformHtmlToXml will generate a malformed XML structure. The last </datafield> can be duplicated. For instance, if a call like: my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values ); with the last value of @field_values is empty, it will return: <?xml version="1.0" encoding="UTF-8"?> <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim"> <record> <datafield2 tag="020" ind1=" " ind2=" "> <subfield code="a">l</subfield> </datafield> <datafield1 tag="100" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="245" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="250" ind1=" " ind2=" "> <subfield code="a">k</subfield> </datafield> <datafield1 tag="260" ind1=" " ind2=" "> <subfield code="b">k</subfield> <subfield code="c">k</subfield> </datafield> </datafield> </record> </collection> Which will result later in the following error: :23: parser error : Opening and ending tag mismatch: record line 6 and datafield </datafield> ^ :24: parser error : Opening and ending tag mismatch: collection line 2 and record </record> ^ :25: parser error : Extra content at the end of the document </collection> Test plan: You can test it along with bug 19289 and confirm that it fixes the problem raised on bug 19289 comment 30 Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 73915 [details] [review] Bug 20540: (follow-up) Remove debug line Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
I picked the tests this bug introduces and can confirm the tests fail without the patches, and pass with it.
Pushed to master for 18.05, thanks to everybody involved!
Is this an enh, or a bug?
(In reply to Nick Clemens from comment #8) > Is this an enh, or a bug? It is a bug that was hidden before bug 19289. Without it, it's not necessary to backport it.