Fixed glob
Paths must be escaped first in case they contain special characters
This commit is contained in:
parent
641afed0a9
commit
d7eedc1068
@ -69,7 +69,7 @@ for module_path in (
|
||||
MINECRAFT_MODEL_READER,
|
||||
):
|
||||
for path in glob.glob(
|
||||
os.path.join(os.path.abspath(module_path), "**", "*.py"), recursive=True
|
||||
os.path.join(glob.escape(os.path.abspath(module_path)), "**", "*.py"), recursive=True
|
||||
):
|
||||
if path not in added_source:
|
||||
rel_path: str = os.path.relpath(path, os.path.dirname(module_path))
|
||||
|
@ -47,7 +47,7 @@ def _init_log():
|
||||
# set up handlers
|
||||
os.makedirs(logs_path, exist_ok=True)
|
||||
# remove all log files older than a week
|
||||
for path in glob.glob(os.path.join(logs_path, "*.log")):
|
||||
for path in glob.glob(os.path.join(glob.escape(logs_path), "*.log")):
|
||||
if (
|
||||
os.path.isfile(path)
|
||||
and os.path.getmtime(path) < time.time() - 3600 * 24 * 7
|
||||
|
@ -92,7 +92,7 @@ def get_languages() -> List[str]:
|
||||
"""Get a list of all supported language codes."""
|
||||
langs = set()
|
||||
for d in _lang_dirs:
|
||||
for l in glob.glob(os.path.join(d, "*.lang")):
|
||||
for l in glob.glob(os.path.join(glob.escape(d), "*.lang")):
|
||||
langs.add(os.path.basename(l)[:-5])
|
||||
return sorted(langs)
|
||||
|
||||
@ -124,7 +124,7 @@ def _find_langs(path: str) -> Tuple[Optional[str], Optional[str], Optional[str]]
|
||||
"""Find the default, language specific and region specific lang paths."""
|
||||
langs = {
|
||||
parse_language_id(os.path.basename(lpath)[:-5]): lpath
|
||||
for lpath in glob.glob(os.path.join(path, "*.lang"))
|
||||
for lpath in glob.glob(os.path.join(glob.escape(path), "*.lang"))
|
||||
}
|
||||
|
||||
default_key = parse_language_id(_default_language)
|
||||
|
@ -106,7 +106,7 @@ class OpenGLResourcePack:
|
||||
os.stat(path).st_mtime
|
||||
for pack in self._resource_pack.pack_paths
|
||||
for path in glob.glob(
|
||||
os.path.join(pack, "**", "*.*"), recursive=True
|
||||
os.path.join(glob.escape(pack), "**", "*.*"), recursive=True
|
||||
)
|
||||
),
|
||||
default=0,
|
||||
|
@ -11,7 +11,7 @@ KeyCharacterSet = set(string.ascii_lowercase + string.digits + "_.")
|
||||
class LangTestCase(unittest.TestCase):
|
||||
def test_lang(self):
|
||||
for lang_dir in lang_dirs():
|
||||
for lang_path in glob.glob(os.path.join(lang_dir, "*")):
|
||||
for lang_path in glob.glob(os.path.join(glob.escape(lang_dir), "*")):
|
||||
self.assertTrue(
|
||||
lang_path.endswith(".lang"),
|
||||
f'{lang_path} does not end with ".lang".',
|
||||
|
Loading…
x
Reference in New Issue
Block a user