mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #51239 from garethgreenaway/51208_file_manage_escaped_double_quotes
[2018.3] Fixes to __build_parts in stringutils
This commit is contained in:
commit
1a2f680e1d
@ -333,7 +333,9 @@ def build_whitespace_split_regex(text):
|
||||
lexer = shlex.shlex(text)
|
||||
lexer.whitespace_split = True
|
||||
lexer.commenters = ''
|
||||
if '\'' in text:
|
||||
if r"'\"" in text:
|
||||
lexer.quotes = ''
|
||||
elif '\'' in text:
|
||||
lexer.quotes = '"'
|
||||
elif '"' in text:
|
||||
lexer.quotes = '\''
|
||||
|
4
tests/integration/files/file/base/issue-51208.sls
Normal file
4
tests/integration/files/file/base/issue-51208.sls
Normal file
@ -0,0 +1,4 @@
|
||||
/tmp/vimrc:
|
||||
file.append:
|
||||
- sources:
|
||||
- salt://test/files/vimrc.stub
|
8
tests/integration/files/file/base/issue-51208/vimrc.stub
Normal file
8
tests/integration/files/file/base/issue-51208/vimrc.stub
Normal file
@ -0,0 +1,8 @@
|
||||
set number
|
||||
syntax on
|
||||
set paste
|
||||
set ruler
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
endif
|
||||
|
@ -2530,6 +2530,22 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
'',
|
||||
]).encode('utf-8'))
|
||||
|
||||
def test_managed_file_issue_51208(self):
|
||||
'''
|
||||
Test to ensure we can handle a file with escaped double-quotes
|
||||
'''
|
||||
name = os.path.join(TMP, 'issue_51208.txt')
|
||||
ret = self.run_state(
|
||||
'file.managed', name=name, source='salt://issue-51208/vimrc.stub'
|
||||
)
|
||||
src = os.path.join(BASE_FILES, 'issue-51208', 'vimrc.stub')
|
||||
with salt.utils.files.fopen(src, 'r') as fp_:
|
||||
master_data = fp_.read()
|
||||
with salt.utils.files.fopen(name, 'r') as fp_:
|
||||
minion_data = fp_.read()
|
||||
self.assertEqual(master_data, minion_data)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
|
||||
class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
marker_start = '# start'
|
||||
|
Loading…
Reference in New Issue
Block a user