diff options
author | Campbell Barton <campbell@blender.org> | 2022-11-01 13:32:46 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-11-01 23:21:10 +0300 |
commit | 12f4ac170658f82ce85d96873cfb32ec786136ec (patch) | |
tree | 526203955a7d6103cf1024511c83a5d051506e56 /source/blender/blenlib/tests/BLI_path_util_test.cc | |
parent | 513dfa179f3d7becf2e88da1084741e0c70a8da7 (diff) |
Fix BLI_path_normalize failing with "." and ".." in the path
The logic to go up a directory (using "..") ran before stripping "/./"
from the path. This caused "/a/b/./../" to result in "/a/b/"
instead of "/a/". Now redundant characters are removed before before
checking for ".." in paths.
Include test to ensure this works as expected.
Diffstat (limited to 'source/blender/blenlib/tests/BLI_path_util_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_path_util_test.cc | 6 |
1 files changed, 6 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 2f0e730129c..51db376e03f 100644 --- a/source/blender/blenlib/tests/BLI_path_util_test.cc +++ b/source/blender/blenlib/tests/BLI_path_util_test.cc @@ -32,6 +32,12 @@ TEST(path_util, Clean_Dot) NORMALIZE("/./././", "/"); NORMALIZE("/a/./././b/", "/a/b/"); } +/* #BLI_path_normalize: complex "/./" -> "/", "//" -> "/", "./path/../" -> "./". */ +TEST(path_util, Clean_Complex) +{ + NORMALIZE("/a/./b/./c/./.././.././", "/a/"); + NORMALIZE("/a//.//b//.//c//.//..//.//..//.//", "/a/"); +} /* #BLI_path_normalize: "//" -> "/" */ TEST(path_util, Clean_DoubleSlash) { |