Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions awscli/customizations/cloudformation/yamlhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def yaml_dump(dict_to_dump):
return yaml.dump(
dict_to_dump,
default_flow_style=False,
allow_unicode=False,
Dumper=FlattenAliasDumper,
)

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/customizations/cloudformation/test_yamlhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ def test_yaml_merge_tag(self):
self.assertTrue(isinstance(output, OrderedDict))
self.assertEqual(output.get('test').get('property'), 'value')

def test_yaml_dump_escapes_non_ascii_characters(self):
# PyYAML defaults write raw UTF-8; CloudFormation shows '?' for non-ASCII
data = {'Value': '\U0001F6A8 firing \U0001F7E2 resolved'}
dumped = yaml_dump(data)
self.assertNotIn('\U0001F6A8', dumped)
self.assertNotIn('\U0001F7E2', dumped)
self.assertIn('\\U0001F6A8', dumped)
self.assertIn('\\U0001F7E2', dumped)
self.assertEqual(yaml_parse(dumped), data)

def test_unroll_yaml_anchors(self):
properties = {
"Foo": "bar",
Expand Down