diff --git a/HISTORY.rst b/HISTORY.rst index 4592daf6..c4d0bdb1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -40,6 +40,8 @@ PlatformIO 3.0 `issue #952 `_) * Don't warn about known ``boards_dir`` option (`pull #949 `_) +* Escape non-valid file name characters when installing a new package (library) + (`issue #985 `_) * Fixed infinite dependency installing when repository consists of multiple libraries (`issue #935 `_) diff --git a/platformio/managers/package.py b/platformio/managers/package.py index 9810a3d5..4e416392 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -126,6 +126,9 @@ class PkgRepoMixin(object): class PkgInstallerMixin(object): + PATH_ESCAPE_CHARS = ("/", "\\", "?", "%", "*", ":", "|", '"', "<", ">", + ".", "(", ")", "&", "#", ",", "'") + SRC_MANIFEST_NAME = ".piopkgmanager.json" FILE_CACHE_VALID = "1m" # 1 month @@ -189,9 +192,11 @@ class PkgInstallerMixin(object): fu = FileUnpacker(source_path, dest_dir) return fu.start() - @staticmethod - def get_install_dirname(manifest): + def get_install_dirname(self, manifest): name = manifest['name'] + for c in self.PATH_ESCAPE_CHARS: + if c in name: + name = name.replace(c, "_") if "id" in manifest: name += "_ID%d" % manifest['id'] return name