forked from platformio/platformio-core
Better escaping for package file names
This commit is contained in:
1 parent
1c5b08de59
commit
8f4c09a600
2 files changed
+26
-27
No files matched your search
@@ -16,6 +16,7 @@ import codecs
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from os.path import basename, getsize, isdir, isfile, islink, join
|
||||
from tempfile import mkdtemp
|
||||
@@ -126,9 +127,6 @@ class PkgRepoMixin(object):
|
||||
|
||||
class PkgInstallerMixin(object):
|
||||
|
||||
PATH_ESCAPE_CHARS = ("/", "\\", "?", "%", "*", ":", "|", '"', "<", ">",
|
||||
".", "(", ")", "&", "#", ",", "'")
|
||||
|
||||
SRC_MANIFEST_NAME = ".piopkgmanager.json"
|
||||
|
||||
FILE_CACHE_VALID = "1m" # 1 month
|
||||
@@ -192,11 +190,9 @@ class PkgInstallerMixin(object):
|
||||
fu = FileUnpacker(source_path, dest_dir)
|
||||
return fu.start()
|
||||
|
||||
def get_install_dirname(self, manifest):
|
||||
name = manifest['name']
|
||||
for c in self.PATH_ESCAPE_CHARS:
|
||||
if c in name:
|
||||
name = name.replace(c, "_")
|
||||
@staticmethod
|
||||
def get_install_dirname(manifest):
|
||||
name = re.sub(r"[^\da-z\_\-\. ]", "_", manifest['name'], flags=re.I)
|
||||
if "id" in manifest:
|
||||
name += "_ID%d" % manifest['id']
|
||||
return name
|
||||
|
||||
Reference in new issue
Block a user