Better escaping for package file names

This commit is contained in:
Ivan Kravets committed 2017-06-24 16:07:40 +03:00
1 parent 1c5b08de59
commit 8f4c09a600
2 files changed
+26 -27

No files matched your search

+4 -8
View File
@@ -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