Skip to content

Commit

Permalink
safeguard JSON parsing (#982) (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored Aug 5, 2024
1 parent e8e6268 commit 2e52b54
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pycsw/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1702,13 +1702,18 @@ def _parse_dc(context, repos, exml):
def _parse_json_record(context, repos, record):
"""Parse JSON record"""

recobj = None

if 'http://www.opengis.net/spec/ogcapi-records-1/1.0/req/record-core' in record.get('conformsTo', []):
LOGGER.debug('Parsing OGC API - Records record model')
recobj = _parse_oarec_record(context, repos, record)
elif 'stac_version' in record:
LOGGER.debug('Parsing STAC resource')
recobj = _parse_stac_resource(context, repos, record)

if recobj is None:
raise RuntimeError('Unsupported JSON metadata format')

atom_xml = atom.write_record(recobj, 'full', context)

_set(context, recobj, 'pycsw:XML', etree.tostring(atom_xml))
Expand Down

0 comments on commit 2e52b54

Please sign in to comment.