From 61e9841e0834bcf86cd4c26b15dad79f23e392cb Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 26 Feb 2016 10:26:49 -0800 Subject: [PATCH] normalize path components to unicode before combining or operating on them Note that this will break if we deal with non-utf8 paths. Fixing this way because converting everythig to byte strings instead is a very invasive task so it should be done as a specific feature to provide support for non-utf8 paths at some point in the future (if needed). --- lib/ansible/parsing/dataloader.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index c54ba78f1fe..c9a5c8e0ee1 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -206,13 +206,15 @@ class DataLoader(): ''' given = unquote(given) + given = to_unicode(given, errors='strict') - if given.startswith("/"): + if given.startswith(u"/"): return os.path.abspath(given) - elif given.startswith("~"): + elif given.startswith(u"~"): return os.path.abspath(os.path.expanduser(given)) else: - return os.path.abspath(os.path.join(self._basedir, given)) + basedir = to_unicode(self._basedir, errors='strict') + return os.path.abspath(os.path.join(basedir, given)) def path_dwim_relative(self, path, dirname, source): '''