mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #13125 from UtahDave/sanitize_strings2
Replace illegal Windows filename chars from cached file paths
This commit is contained in:
commit
c7cea970dd
@ -515,11 +515,15 @@ class Client(object):
|
||||
else:
|
||||
return ''
|
||||
else:
|
||||
if salt.utils.is_windows():
|
||||
netloc = salt.utils.sanitize_win_path_string(url_data.netloc)
|
||||
else:
|
||||
netloc = url_data.netloc
|
||||
dest = salt.utils.path_join(
|
||||
self.opts['cachedir'],
|
||||
'extrn_files',
|
||||
saltenv,
|
||||
url_data.netloc,
|
||||
netloc,
|
||||
url_data.path
|
||||
)
|
||||
destdir = os.path.dirname(dest)
|
||||
|
@ -33,6 +33,7 @@ import types
|
||||
import warnings
|
||||
import yaml
|
||||
from calendar import month_abbr as months
|
||||
from string import maketrans
|
||||
|
||||
# Try to load pwd, fallback to getpass if unsuccessful
|
||||
try:
|
||||
@ -1288,6 +1289,20 @@ def is_windows():
|
||||
return sys.platform.startswith('win')
|
||||
|
||||
|
||||
def sanitize_win_path_string(winpath):
|
||||
'''
|
||||
Remove illegal path characters for windows
|
||||
'''
|
||||
intab = '<>:|?*'
|
||||
outtab = '_' * len(intab)
|
||||
trantab = maketrans(intab, outtab)
|
||||
if isinstance(winpath, str):
|
||||
winpath = winpath.translate(trantab)
|
||||
elif isinstance(winpath, unicode):
|
||||
winpath = winpath.translate(dict((ord(c), u'_') for c in intab))
|
||||
return winpath
|
||||
|
||||
|
||||
@real_memoize
|
||||
def is_linux():
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user