Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenlib/BLI_path_util.h2
-rw-r--r--source/blender/blenlib/intern/path_util.c18
-rw-r--r--source/blender/render/intern/source/render_result.c3
3 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index bade390d056..8daaff1cea6 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -108,6 +108,8 @@ void BLI_cleanup_dir(const char *relabase, char *dir) ATTR_NONNULL(2);
/* doesn't touch trailing slash */
void BLI_cleanup_path(const char *relabase, char *path) ATTR_NONNULL(2);
+void BLI_filename_make_safe(char *fname) ATTR_NONNULL(1);
+
/* go back one directory */
bool BLI_parent_dir(char *path) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 3fff22218e2..793f4d589cd 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -428,6 +428,24 @@ void BLI_cleanup_file(const char *relabase, char *path)
BLI_del_slash(path);
}
+
+/**
+ * Make given name safe to be used in paths.
+ *
+ * For now, simply replaces reserved chars (as listed in
+ * http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words )
+ * by underscores ('_').
+ */
+void BLI_filename_make_safe(char *fname)
+{
+ char *invalid = "/\\?%*:|\"<>. ";
+ char *c;
+
+ for (; *fname && (fname = strpbrk(fname, invalid)); fname++) {
+ *fname = '_';
+ }
+}
+
/**
* Does path begin with the special "//" prefix that Blender uses to indicate
* a path relative to the .blend file.
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index de87fb200ae..154c0c8570c 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -1074,6 +1074,9 @@ void render_result_exr_file_path(Scene *scene, const char *layname, int sample,
BLI_snprintf(name, sizeof(name), "%s_%s_%s%d.exr", fi, scene->id.name + 2, layname, sample);
}
+ /* Make name safe for paths, see T43275. */
+ BLI_filename_make_safe(name);
+
BLI_make_file_string("/", filepath, BKE_tempdir_session(), name);
}