diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-05-30 16:43:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-30 16:43:43 +0200 |
commit | fcb60fa2cd496df1b054840727e13210d3d24b59 (patch) | |
tree | 84e9d5239763e84f575731adc0046ca128efa0e5 /core/project_settings.cpp | |
parent | c6b96050d0675ee64652b4995137a1109508016b (diff) | |
parent | 9ad9d1f3b3a5e6d1440a0f8d38e1b3246e00412d (diff) |
Merge pull request #29315 from akien-mga/fix-paths-localization
Don't localize paths that contain but are not in the resource path
Diffstat (limited to 'core/project_settings.cpp')
-rw-r--r-- | core/project_settings.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 2fd22d4789..4c37142ffd 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -75,11 +75,19 @@ String ProjectSettings::localize_path(const String &p_path) const { memdelete(dir); - if (!cwd.begins_with(resource_path)) { + // Ensure that we end with a '/'. + // This is important to ensure that we do not wrongly localize the resource path + // in an absolute path that just happens to contain this string but points to a + // different folder (e.g. "/my/project" as resource_path would be contained in + // "/my/project_data", even though the latter is not part of res://. + // `plus_file("")` is an easy way to ensure we have a trailing '/'. + const String res_path = resource_path.plus_file(""); + + if (!cwd.begins_with(res_path)) { return p_path; }; - return cwd.replace_first(resource_path, "res:/"); + return cwd.replace_first(res_path, "res://"); } else { memdelete(dir); |