1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Merge pull request #100075 from demolke/simplify

Fix handling of leading `..` in simplify_path
This commit is contained in:
Thaddeus Crews
2024-12-09 14:33:34 -06:00
2 changed files with 5 additions and 1 deletions

View File

@@ -4599,7 +4599,7 @@ String String::simplify_path() const {
dirs.remove_at(i);
i--;
} else if (d == "..") {
if (i != 0) {
if (i != 0 && dirs[i - 1] != "..") {
dirs.remove_at(i);
dirs.remove_at(i - 1);
i -= 2;

View File

@@ -1687,6 +1687,10 @@ TEST_CASE("[String] Path functions") {
for (int i = 0; i < 3; 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") {