diff options
Diffstat (limited to 'loader')
-rw-r--r-- | loader/atlas.cpp | 22 | ||||
-rw-r--r-- | loader/impl.hpp | 1 | ||||
-rw-r--r-- | loader/loader.hpp | 1 |
3 files changed, 11 insertions, 13 deletions
diff --git a/loader/atlas.cpp b/loader/atlas.cpp index ede9f8ec..0f492119 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -27,6 +27,16 @@ StringView loader_::make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, St return StringView{buf}; } +bool loader_::check_atlas_name(StringView str) noexcept +{ + if (!str || str[0] == '.' || str[0] == '/') + return false; + if (str.findAny("\\\"'\n\r\t\a\033\0|$!%{}#^*?<>&;:^"_s) || str.find("/."_s)) + return false; + + return true; +} + } // namespace floormat namespace floormat::loader_detail { @@ -129,16 +139,4 @@ void loader_impl::get_anim_atlas_list() } } -bool loader_impl::check_atlas_name(StringView str) -{ - if (str.isEmpty()) - return false; - if (str.findAny("\n\r\t\0\\|$<>&;:^'\""_s) || str.find("/."_s)) - return false; - if (str[0] == '.' || str[0] == '/') - return false; - - return true; -} - } // namespace floormat::loader_detail diff --git a/loader/impl.hpp b/loader/impl.hpp index d0159a3d..13087ff3 100644 --- a/loader/impl.hpp +++ b/loader/impl.hpp @@ -54,7 +54,6 @@ struct loader_impl final : loader_ StringView startup_directory() noexcept override; static void system_init(); static bool chdir(StringView pathname); - [[nodiscard]] static bool check_atlas_name(StringView name); void ensure_plugins(); explicit loader_impl(); diff --git a/loader/loader.hpp b/loader/loader.hpp index 484c5102..ce331203 100644 --- a/loader/loader.hpp +++ b/loader/loader.hpp @@ -40,6 +40,7 @@ struct loader_ virtual const vobj_info& vobj(StringView name) = 0; virtual ArrayView<struct vobj_info> vobj_list() = 0; static StringView make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, StringView name); + [[nodiscard]] static bool check_atlas_name(StringView name) noexcept; loader_(const loader_&) = delete; loader_& operator=(const loader_&) = delete; |