https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43776

--- Comment #2 from Adolfo Rodríguez Taboada <[email protected]> ---
Created attachment 211547
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211547&action=edit
Bug 43776: Repair and report invalid characters in TransformHtmlToMarc

TransformHtmlToMarc stripped non-XML characters from the submitted values
inline and silently, so the cataloguer was never told their data had been
changed. Bug 35104 removed that stripping on the assumption that store()
handled it, and the RM follow-up restored it without any report.

TransformHtmlToMarc now checks its result the same way
Koha::Biblio::Metadata does when saving: it serialises the record and, if the
XML does not read back, repairs the recoverable faults with repair_marcxml.
The repairs are returned through an optional third argument. Unrecoverable
input throws Koha::Exceptions::Metadata::Invalid.

Repairs are passed to AddBiblio and ModBiblio with the new repairs option.
They are recorded as metadata error rows and reported as warnings, as
Koha::Biblio::Metadata->store already does for repairs made on save. The
cataloguing editor therefore shows the "Record saved with modifications"
banner after a save, and the form shows the repaired values when a duplicate
check stops the save. Merge reports them as merge warnings.

Unrecoverable input is caught by addbiblio.pl, merge.pl and the automatic
linker service and reported as an error instead of a 500. Authority callers
keep the inline stripping, as authority records are not stored through
Koha::Biblio::Metadata; that is left for a follow-up decision.

Koha::Biblio::Metadata gains add_repairs (the recording loop from store) and
repair_messages (the same text as a list, for records not yet saved).

To test:
1. Apply this patch on top of bug 43025 (which depends on bug 35104).
2. In the cataloguing editor, add a new record and paste a control character
   (e.g. U+001F) into a subfield value, then save.
   => The record saves and the "Record saved with modifications" banner
      names the character that was removed.
3. Edit a record, paste the same character, and save a record that trips the
   duplicate check so the form is redisplayed without saving.
   => The "Data repaired in the form" notice names the character; nothing
      is saved.
4. Merge two records where one has the same character in a field.
   => The merge completes and its warnings name the repair.
5. Run prove t/db_dependent/Biblio/TransformHtmlToMarc.t
   => All tests pass.
6. Run prove t/db_dependent/Biblio.t t/db_dependent/Koha/Biblio/Metadata.t
   => All tests pass.

Sponsored-by: OpenFifth
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Adolfo Rodríguez <[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/

Reply via email to