mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
commit
aca87abe40
@ -1118,7 +1118,7 @@ def _get_template_texts(source_list=None,
|
||||
tmplines = None
|
||||
with salt.utils.files.fopen(rndrd_templ_fn, 'rb') as fp_:
|
||||
tmplines = fp_.read()
|
||||
tmplines = tmplines.decode(__salt_system_encoding__)
|
||||
tmplines = salt.utils.stringutils.to_unicode(tmplines)
|
||||
tmplines = tmplines.splitlines(True)
|
||||
if not tmplines:
|
||||
msg = 'Failed to read rendered template file {0} ({1})'
|
||||
|
@ -791,10 +791,10 @@ def backup_minion(path, bkroot):
|
||||
def get_encoding(path):
|
||||
'''
|
||||
Detect a file's encoding using the following:
|
||||
- Check for ascii
|
||||
- Check for Byte Order Marks (BOM)
|
||||
- Check for UTF-8 Markers
|
||||
- Check System Encoding
|
||||
- Check for ascii
|
||||
|
||||
Args:
|
||||
|
||||
@ -867,10 +867,6 @@ def get_encoding(path):
|
||||
except os.error:
|
||||
raise CommandExecutionError('Failed to open file')
|
||||
|
||||
# Check for ASCII first
|
||||
if check_ascii(data):
|
||||
return 'ASCII'
|
||||
|
||||
# Check for Unicode BOM
|
||||
encoding = check_bom(data)
|
||||
if encoding:
|
||||
@ -884,4 +880,8 @@ def get_encoding(path):
|
||||
if check_system_encoding(data):
|
||||
return __salt_system_encoding__
|
||||
|
||||
# Check for ASCII first
|
||||
if check_ascii(data):
|
||||
return 'ASCII'
|
||||
|
||||
raise CommandExecutionError('Could not detect file encoding')
|
||||
|
1
tests/integration/files/file/base/issue-49043
Normal file
1
tests/integration/files/file/base/issue-49043
Normal file
@ -0,0 +1 @@
|
||||
{{unicode_string}}
|
16
tests/integration/files/file/base/issue-49043.sls
Normal file
16
tests/integration/files/file/base/issue-49043.sls
Normal file
@ -0,0 +1,16 @@
|
||||
somefile-exists:
|
||||
file:
|
||||
- managed
|
||||
- name: {{ pillar['name'] }}
|
||||
|
||||
somefile-blockreplace:
|
||||
file:
|
||||
- blockreplace
|
||||
- append_if_not_found: true
|
||||
- name: {{ pillar['name'] }}
|
||||
- template: jinja
|
||||
- source: salt://issue-49043
|
||||
- require:
|
||||
- file: somefile-exists
|
||||
- context:
|
||||
unicode_string: "\xe4\xf6\xfc"
|
@ -3746,6 +3746,25 @@ class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self._read(name),
|
||||
self.with_matching_block_and_marker_end_not_after_newline)
|
||||
|
||||
@with_tempfile()
|
||||
def test_issue_49043(self, name):
|
||||
ret = self.run_function(
|
||||
'state.sls',
|
||||
mods='issue-49043',
|
||||
pillar={'name': name},
|
||||
)
|
||||
log.error("ret = %s", repr(ret))
|
||||
diff = '--- \n+++ \n@@ -0,0 +1,3 @@\n'
|
||||
diff += dedent('''\
|
||||
+#-- start managed zone --
|
||||
+äöü
|
||||
+#-- end managed zone --
|
||||
''')
|
||||
job = 'file_|-somefile-blockreplace_|-{}_|-blockreplace'.format(name)
|
||||
self.assertEqual(
|
||||
ret[job]['changes']['diff'],
|
||||
diff)
|
||||
|
||||
|
||||
class RemoteFileTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user