diff --git a/salt/modules/config.py b/salt/modules/config.py index ce490234e1b3..0792d0a30b26 100644 --- a/salt/modules/config.py +++ b/salt/modules/config.py @@ -7,7 +7,6 @@ from __future__ import absolute_import, print_function, unicode_literals import copy import fnmatch -import re import os import logging @@ -129,10 +128,10 @@ def valid_fileproto(uri): salt '*' config.valid_fileproto salt://path/to/file ''' - try: - return bool(re.match('^(?:salt|https?|ftp)://', uri)) - except Exception: - return False + return ( + six.moves.urllib.parse.urlparse(uri).scheme in + salt.utils.files.VALID_PROTOS + ) def option( diff --git a/salt/modules/cp.py b/salt/modules/cp.py index d1deede8e9eb..3c5e8215a63a 100644 --- a/salt/modules/cp.py +++ b/salt/modules/cp.py @@ -492,7 +492,7 @@ def cache_file(path, saltenv='base', source_hash=None): contextkey = '{0}_|-{1}_|-{2}'.format('cp.cache_file', path, saltenv) - path_is_remote = _urlparse(path).scheme in ('http', 'https', 'ftp') + path_is_remote = _urlparse(path).scheme in salt.utils.files.REMOTE_PROTOS try: if path_is_remote and contextkey in __context__: # Prevent multiple caches in the same salt run. Affects remote URLs diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index a1e3a055a2f5..311576f3e3d5 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -1522,7 +1522,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs): continue # Is the installer in a location that requires caching - if installer.startswith(('salt:', 'http:', 'https:', 'ftp:')): + if __salt__['config.valid_fileproto'](installer): # Check for the 'cache_dir' parameter in the .sls file # If true, the entire directory will be cached instead of the