fix [#27922] using preset_paths() with an absolute path returns twice the same thing
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 15:33:27 +0000 (15:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jul 2011 15:33:27 +0000 (15:33 +0000)
raise an error when an invalid subdir is passed to preset_paths()

release/scripts/modules/bpy/utils.py

index 7c0d3d24cba546c2c04e0b729bd0eedc91384dc9..57d3e6dd703e1c6911b376e0b232d7f71e570001 100644 (file)
@@ -298,11 +298,18 @@ _presets = _os.path.join(_scripts[0], "presets")  # FIXME - multiple paths
 def preset_paths(subdir):
     """
     Returns a list of paths for a specific preset.
+
+    :arg subdir: preset subdirectory (must not be an absolute path).
+    :type subdir: string
+    :return: script paths.
+    :rtype: list
     """
     dirs = []
     for path in script_paths("presets", all=True):
         directory = _os.path.join(path, subdir)
-        if _os.path.isdir(directory):
+        if not directory.startswith(path):
+            raise Exception("invalid subdir given %r" % subdir)
+        elif _os.path.isdir(directory):
             dirs.append(directory)
     return dirs