https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43196
--- Comment #3 from Tomás Cohen Arazi (tcohen) <[email protected]> --- Created attachment 203351 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203351&action=edit Bug 43196: Reject malformed MARC records in PUT /biblios MARC::Record parsers silently return empty records on invalid input: - new_from_mij_structure(undef) returns a blank record (MiJ) - new_from_usmarc(garbage) returns a blank record with warnings - new_from_xml(valid-but-empty) returns a blank record The PUT /biblios endpoint passed these blank records to ModBiblio, which overwrote existing bibliographic data with an empty record (only system-generated 005 and 999 fields survive). Wrap each parser call in try/catch (for MARCXML which dies on malformed XML) and validate the resulting record has at least one field before proceeding. Return 400 if parsing fails or produces an empty record. Note: MARC::Record::MiJ upstream has been patched to croak on undef/invalid input (perl4lib/marc-perl#28), but Koha needs this defensive check regardless for USMARC and empty-but-valid cases. Test plan: 1. Apply the regression tests from the previous commit 2. Run: $ prove t/db_dependent/api/v1/biblios.t => FAIL: put() malformed body tests fail 3. Apply this patch 4. Repeat step 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomás Cohen Arazi <[email protected]> -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
