Repository navigation
escape JSON only when embedded in HTML (#1282) - #1285
Open
ahmed-hassan19 wants to merge 1 commit into
Open
ahmed-hassan19 wants to merge 1 commit into
ahmed-hassan19 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
to_jsonreturns plain JSON again, so OGC API - Records and STAC API JSON responses keep<and>instored values. The
</>escaping from #1249 moves to a newto_json_html, whichrender_j2_templateregisters as the
to_jsonfilter and global (default and fallback environments). Templates and theiroutput are unchanged, and custom templates that use
to_jsonkeep the escaped output.Tests:
tests/unittests/test_ogc_api_util.py:to_jsonkeeps<,&and>; theto_jsonfilter doesnot emit
</script>with default templates or with thetemplates.pathfallback.tests/functionaltests/suites/oarec/test_oarec_util.py:test_to_jsonexpects unescaped output thatparses back to the input; the safeguard output in Jinja2 templates #1249 cases move to
test_to_json_html.With the reproduction from #1282,
?f=jsonreturns"title":"Depth < 10 m & slope > 5%", and the item anditems 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)