Skip to content

escape JSON only when embedded in HTML (#1282) - #1285

Open
ahmed-hassan19 wants to merge 1 commit into
geopython:masterfrom
ahmed-hassan19:issue-1282
Open

ahmed-hassan19 wants to merge 1 commit into
geopython:masterfrom
ahmed-hassan19:issue-1282

Conversation

@ahmed-hassan19

Copy link
Copy Markdown

Overview

to_json returns plain JSON again, so OGC API - Records and STAC API JSON responses keep < and > in
stored values. The </> escaping from #1249 moves to a new to_json_html, which render_j2_template
registers as the to_json filter and global (default and fallback environments). Templates and their
output are unchanged, and custom templates that use to_json keep the escaped output.

Tests:

  • tests/unittests/test_ogc_api_util.py: to_json keeps <, & and >; the to_json filter does
    not emit </script> with default templates or with the templates.path fallback.
  • tests/functionaltests/suites/oarec/test_oarec_util.py: test_to_json expects unescaped output that
    parses back to the input; the safeguard output in Jinja2 templates #1249 cases move to test_to_json_html.

With the reproduction from #1282, ?f=json returns "title":"Depth < 10 m & slope > 5%", and the item and
items HTML pages are byte-identical to master apart from timestamps.

Related Issue / Discussion

Fixes #1282. Follows up #1249; keeps the filter registration from #1243.

Additional Information

None.

Contributions and Licensing

(as per https://github.com/geopython/pycsw/blob/master/CONTRIBUTING.rst#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pycsw. I confirm that my contributions to pycsw will be compatible with the pycsw license guidelines at the time of contribution.
  • I have already previously agreed to the pycsw Contributions and Licensing Guidelines

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OGC API - Records JSON responses HTML-escape < and > since #1249

1 participant