Escape non-valid file name characters when installing a new package (library) // Resolve #985

This commit is contained in:
Ivan Kravets
2017-06-24 15:20:33 +03:00
parent f6960a0f98
commit d8a0272bec
2 changed files with 9 additions and 2 deletions

View File

@ -40,6 +40,8 @@ PlatformIO 3.0
`issue #952 <https://github.com/platformio/platformio-core/issues/952>`_)
* Don't warn about known ``boards_dir`` option
(`pull #949 <https://github.com/platformio/platformio-core/pull/949>`_)
* Escape non-valid file name characters when installing a new package (library)
(`issue #985 <https://github.com/platformio/platformio-core/issues/985>`_)
* Fixed infinite dependency installing when repository consists of multiple
libraries
(`issue #935 <https://github.com/platformio/platformio-core/issues/935>`_)

View File

@ -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