From 1d3be8c453d870c11658ce9c76df12017180d6eb Mon Sep 17 00:00:00 2001 From: Paul Joannon Date: Thu, 11 Jan 2018 12:59:31 +0100 Subject: [PATCH] fix API string path (cherry picked from commit a35c8bbdc7bdf2cd5ca640b572dd4ad1e170c260) --- core/io/image_loader.cpp | 2 +- core/io/resource_saver.cpp | 2 +- core/ustring.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 999c9a8ca27..8ebd9d6cd92 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -37,7 +37,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { get_recognized_extensions(&extensions); for (List::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(p_extension.get_extension()) == 0) + if (E->get().nocasecmp_to(p_extension) == 0) return true; } diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 609dd7e93ca..3dcd94880a9 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -56,7 +56,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t for (List::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension.get_extension()) == 0) + if (E->get().nocasecmp_to(extension) == 0) recognized = true; } diff --git a/core/ustring.cpp b/core/ustring.cpp index 954f5902184..e1d1949524b 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3713,8 +3713,8 @@ String String::get_file() const { String String::get_extension() const { int pos = find_last("."); - if (pos < 0) - return *this; + if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) + return ""; return substr(pos + 1, length()); } @@ -3792,7 +3792,7 @@ String String::percent_decode() const { String String::get_basename() const { int pos = find_last("."); - if (pos < 0) + if (pos < 0 || pos < MAX(find_last("/"), find_last("\\"))) return *this; return substr(0, pos);