You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Fix handling of leading .. in simplify_path
Prior to this `..\..\texture.png` was incorrectly simplified to `texture.png`
This commit is contained in:
@@ -4608,7 +4608,7 @@ String String::simplify_path() const {
|
|||||||
dirs.remove_at(i);
|
dirs.remove_at(i);
|
||||||
i--;
|
i--;
|
||||||
} else if (d == "..") {
|
} else if (d == "..") {
|
||||||
if (i != 0) {
|
if (i != 0 && dirs[i - 1] != "..") {
|
||||||
dirs.remove_at(i);
|
dirs.remove_at(i);
|
||||||
dirs.remove_at(i - 1);
|
dirs.remove_at(i - 1);
|
||||||
i -= 2;
|
i -= 2;
|
||||||
|
|||||||
@@ -1687,6 +1687,10 @@ TEST_CASE("[String] Path functions") {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
CHECK(String(file_name[i]).is_valid_filename() == valid[i]);
|
CHECK(String(file_name[i]).is_valid_filename() == valid[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(String("res://texture.png") == String("res://folder/../folder/../texture.png").simplify_path());
|
||||||
|
CHECK(String("res://texture.png") == String("res://folder/sub/../../texture.png").simplify_path());
|
||||||
|
CHECK(String("res://../../texture.png") == String("res://../../texture.png").simplify_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[String] hash") {
|
TEST_CASE("[String] hash") {
|
||||||
|
|||||||
Reference in New Issue
Block a user