Fix encoding issues with file paths. (#50830)

* Fix encoding issues with file paths.

Discovered while testing with ANSIBLE_CONFIG env var set to a path
that contained unicode characters while LC_ALL=C.

* Fix unit tests.

* Fix another path encoding issue.
This commit is contained in:
Matt Clay
2019-01-14 13:06:47 -08:00
committed by GitHub
parent 15b1a31aa8
commit 465df0ef8d
5 changed files with 13 additions and 13 deletions

View File

@@ -77,12 +77,12 @@ class VarsModule(BaseVarsPlugin):
try:
found_files = []
# load vars
opath = os.path.realpath(os.path.join(self._basedir, subdir))
b_opath = os.path.realpath(to_bytes(os.path.join(self._basedir, subdir)))
opath = to_text(b_opath)
key = '%s.%s' % (entity.name, opath)
if cache and key in FOUND:
found_files = FOUND[key]
else:
b_opath = to_bytes(opath)
# no need to do much if path does not exist for basedir
if os.path.exists(b_opath):
if os.path.isdir(b_opath):