Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compat tojson filter for jinja2 versions missing it #56596

Merged
merged 1 commit into from May 18, 2019

Conversation

sivel
Copy link
Member

@sivel sivel commented May 17, 2019

SUMMARY

Add compat tojson filter for jinja2 versions missing it

The jinja2 version available on EL7 is missing the tojson filter, which was added in jinja2 2.9.

This PR adds a compat when missing. It's not 100% equivalent, since jinja2 does extra escaping, but we are passing to the escape filter already, so there should be no problem.

jinja2 uses:

    if dumper is None:
        dumper = json.dumps
    rv = dumper(obj, **kwargs) \
        .replace(u'<', u'\\u003c') \
        .replace(u'>', u'\\u003e') \
        .replace(u'&', u'\\u0026') \
        .replace(u"'", u'\\u0027')
    return Markup(rv)
ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
COMPONENT NAME

docs/bin/plugin_formatter.py

ADDITIONAL INFORMATION

@sivel sivel requested review from abadger and acozine May 17, 2019 17:56
@sivel
Copy link
Member Author

sivel commented May 17, 2019

cc @nirik

@ansibot
Copy link
Contributor

ansibot commented May 17, 2019

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. needs_triage Needs a first human triage before being processed. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 17, 2019
@acozine acozine removed the needs_triage Needs a first human triage before being processed. label May 18, 2019
@acozine
Copy link
Contributor

acozine commented May 18, 2019

As discussed on #ansible-devel, this preserves the functionality of #56041 with support for older versions of jinja2. Thanks @sivel for the patch.

@acozine acozine merged commit 3f4a22d into ansible:devel May 18, 2019
abadger pushed a commit to abadger/ansible that referenced this pull request May 18, 2019
…nsible#56596)

(cherry picked from commit 3f4a22d)

Co-authored-by: Matt Martz <matt@sivel.net>
acozine pushed a commit that referenced this pull request May 19, 2019
…56596) (#56606)

(cherry picked from commit 3f4a22d)

Co-authored-by: Matt Martz <matt@sivel.net>
acozine pushed a commit to acozine/ansible that referenced this pull request May 20, 2019
acozine pushed a commit to acozine/ansible that referenced this pull request May 20, 2019
acozine added a commit that referenced this pull request May 21, 2019
* Improve rendering of default lists (#56041)

(cherry picked from commit 53ed1bf)

* Add compat tojson filter for jinja2 versions missing it (#56596)

(cherry picked from commit 3f4a22d)
acozine added a commit that referenced this pull request May 21, 2019
* Improve rendering of default lists (#56041)

(cherry picked from commit 53ed1bf)

* Add compat tojson filter for jinja2 versions missing it (#56596)

(cherry picked from commit 3f4a22d)
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants