Skip to content

Commit 9715afa

Browse files
adding newline characters to special characters that require quoting … (#829)
* adding newline characters to special characters that require quoting in YAML * updating copyrights...
1 parent d3b7e68 commit 9715afa

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/src/main/python/wlsdeploy/yaml/yaml_translator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2019, 2021, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
Module to handle translating between Yaml files and Python dictionaries.
@@ -102,7 +102,7 @@ class PythonToYaml(object):
102102
_class_name = 'PythonToYaml'
103103
# 4 spaces
104104
_indent_unit = ' '
105-
_requires_quotes_chars_regex = '[:{}\[\],&*#?|<>=!%@`-]'
105+
_requires_quotes_chars_regex = '[\r\n:{}\[\],&*#?|<>=!%@`-]'
106106

107107
def __init__(self, dictionary):
108108
# Fix error handling for None

core/src/test/python/translator_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2021, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import os
@@ -73,6 +73,7 @@ def testPythonToYaml(self):
7373
pythonDict['foo'] = 'test \'legal\' yaml'
7474
pythonDict['bar'] = 'test "legal" yaml'
7575
pythonDict['baz'] = 'test \'legal\' yaml'
76+
pythonDict['newline'] = 'test embedded\nnewline yaml'
7677

7778
translator = PythonToFile(pythonDict)
7879
translator.write_to_file(self._target_yaml_file)
@@ -83,10 +84,13 @@ def testPythonToYaml(self):
8384
self.assertEqual('foo' in newPythonDict, True)
8485
self.assertEqual('bar' in newPythonDict, True)
8586
self.assertEqual('baz' in newPythonDict, True)
87+
self.assertEquals('newline' in newPythonDict, True)
8688

8789
quotedValue = newPythonDict['foo']
8890
self.assertEqual(quotedValue, 'test \'legal\' yaml')
8991
quotedValue = newPythonDict['bar']
9092
self.assertEqual(quotedValue, 'test "legal" yaml')
9193
quotedValue = newPythonDict['baz']
9294
self.assertEqual(quotedValue, 'test \'legal\' yaml')
95+
quotedValue = newPythonDict['newline']
96+
self.assertEqual(quotedValue, 'test embedded\nnewline yaml')

0 commit comments

Comments
 (0)