Center-for-Research-Libraries / crl-serials-validator

Validate bibliographic and holdings data for shared print.
GNU General Public License v3.0
0 stars 1 forks source link

marc_fields crashes on MARC records with consecutive dollar signs #12

Closed nflorin closed 3 years ago

nflorin commented 3 years ago

When the field is being converted into a dict it breaks the string on dollar signs, leading to a "subfield" without a subfield indicator, causing an IndexError and crash. This is also likely to happen with a line that ends with a dollar sign.

A (shortened) example field, with the "$$d":

=040 \\$aNLM$beng$cNLM$dNSD$dIUL$dDLC$dCQ$$dLND$dOCLCQ$dL2U$dOCLCQ$dCPO$dDLC$dCN4X3

nflorin commented 3 years ago

Error mostly occurs in 040 (cataloging source) lines, because of OCLC codes like "CQ$".

nflorin commented 3 years ago

Fixed. Fixed 040 line handling, issue is optionally logged as warning in other fields. Also on RecursionError, __getattr__ informs of the bad attribute asked for.