diff options
author | Campbell Barton <campbell@blender.org> | 2022-11-01 14:02:08 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-11-01 23:21:10 +0300 |
commit | cc6f41f8a53f7f0392afa59e6da8ebc3849fc03c (patch) | |
tree | e25c65ab46eb06847f32d93ee8cf283f441ab4bc /source/blender/blenlib/tests/BLI_path_util_test.cc | |
parent | 12f4ac170658f82ce85d96873cfb32ec786136ec (diff) |
Fix BLI_path_parent_dir failing on paths ending with ".."
The check for BLI_path_normalize having succeeded only checked for a
trailing "../" which isn't correct. This caused going up a directory
in the file selector to do nothing on directories ending with "..".
This also caused an empty path to expand into "../" because
BLI_path_extension_check didn't account for this case.
Resolve using BLI_path_name_at_index which extracts the last component
of the path without having to match the the surrounding slashes.
Diffstat (limited to 'source/blender/blenlib/tests/BLI_path_util_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_path_util_test.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc index 51db376e03f..93922b41b23 100644 --- a/source/blender/blenlib/tests/BLI_path_util_test.cc +++ b/source/blender/blenlib/tests/BLI_path_util_test.cc @@ -75,6 +75,17 @@ TEST(path_util, ParentDir) PARENT_DIR("/a/b", "/a/"); PARENT_DIR("/a", "/"); PARENT_DIR("/", "/"); + PARENT_DIR("", ""); + + /* Ensure trailing dots aren't confused with parent path. */ + PARENT_DIR("/.../.../.../", "/.../.../"); + PARENT_DIR("/.../.../...", "/.../.../"); + + PARENT_DIR("/a../b../c../", "/a../b../"); + PARENT_DIR("/a../b../c..", "/a../b../"); + + PARENT_DIR("/a./b./c./", "/a./b./"); + PARENT_DIR("/a./b./c.", "/a./b./"); # undef PARENT_DIR } |