Skip to content

Commit

Permalink
Normalize how None is handled in quote filter. Fixes #32174 (#71473)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivel committed Aug 27, 2020
1 parent addee06 commit a1a624b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/32174-normalize-None-quote.yml
@@ -0,0 +1,3 @@
bugfixes:
- quote filter - normalize how ``None`` is handled, to match Python3 behavior
(https://github.com/ansible/ansible/issues/32174)
2 changes: 2 additions & 0 deletions lib/ansible/plugins/filter/core.py
Expand Up @@ -110,6 +110,8 @@ def strftime(string_format, second=None):

def quote(a):
''' return its argument quoted for shell usage '''
if a is None:
a = u''
return shlex_quote(to_text(a))


Expand Down
7 changes: 7 additions & 0 deletions test/integration/targets/filter_core/tasks/main.yml
Expand Up @@ -601,3 +601,10 @@
bar: 123
thing_items: '{{ thing_dict.items() }}'
thing_range: '{{ range(10) }}'

- name: Assert that quote works on None
assert:
that:
- thing|quote == "''"
vars:
thing: null

0 comments on commit a1a624b

Please sign in to comment.