Skip to content

Parsers silently accepts broken data #39

Description

@nichtich

If input is not valid MARC serialization, the result of parsing is not well-defined. I guess from certain point of view this is not a bug but a feature, but I wish to get at least a warning on broken input.

Some examples:

console.log(Marc.parse("abc", "iso2709"))
Record { leader: 'abc', fields: [] }
console.log(Marc.parse("123", "iso2709"))
Record {
  leader: '123',
  fields: [
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ],
    [ '123', '12' ]
  ]
}
// broken XML, malformed leader and tag
const marcxml = `<record
<leader>X</leader>
<controlfield tag="1234">YYY</controlfield>
</record>`;
console.log(Marc.parse(marcxml, 'marcxml'))
Record { leader: 'X', fields: [ [ '123', '>YYY' ] ] }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions