From 5cc45a7c9ba8ce11266caf7e0b32046db34352c3 Mon Sep 17 00:00:00 2001 From: Llennpie <44985633+Llennpie@users.noreply.github.com> Date: Sat, 6 Jan 2024 20:51:03 -0500 Subject: [PATCH] Fix small CC editor bugs --- src/saturn/imgui/saturn_imgui_cc_editor.cpp | 12 ++++++------ src/saturn/saturn_colors.cpp | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/saturn/imgui/saturn_imgui_cc_editor.cpp b/src/saturn/imgui/saturn_imgui_cc_editor.cpp index 0c05d5d7..471a721a 100644 --- a/src/saturn/imgui/saturn_imgui_cc_editor.cpp +++ b/src/saturn/imgui/saturn_imgui_cc_editor.cpp @@ -270,12 +270,11 @@ void OpenModelCCSelector(Model model, std::vector list, std::string // Right-Click Menu if (ImGui::BeginPopupContextItem()) { - if (label_name_lower != "default" || label_name_lower != "../default") { - ImGui::Text("%s.gs", label_name.c_str()); - imgui_bundled_tooltip((model.FolderPath + "/colorcodes/" + label_name + ".gs").c_str()); - ImGui::Separator(); + ImGui::Text("%s.gs", label_name.c_str()); + imgui_bundled_tooltip((model.FolderPath + "/colorcodes/" + label_name + ".gs").c_str()); - // Delete GS File + // Delete GS File + if (label_name_lower != "default" && label_name_lower != "../default") { if (ImGui::Button(ICON_FK_TRASH " Delete File")) ImGui::OpenPopup("###delete_m_gs_file"); if (ImGui::BeginPopup("###delete_m_gs_file")) { @@ -293,7 +292,8 @@ void OpenModelCCSelector(Model model, std::vector list, std::string ImGui::EndPopup(); } } - + + ImGui::Separator(); ImGui::TextDisabled("%i color code(s)", list.size()); if (ImGui::Button(ICON_FK_UNDO " Refresh")) { RefreshColorCodeList(); diff --git a/src/saturn/saturn_colors.cpp b/src/saturn/saturn_colors.cpp index 5bb7af40..ff3a03dc 100644 --- a/src/saturn/saturn_colors.cpp +++ b/src/saturn/saturn_colors.cpp @@ -254,6 +254,11 @@ void SaveGSFile(ColorCode colorCode, std::string filePath) { } void DeleteGSFile(std::string filePath) { + // Disallow paths that reach out of bounds + if (filePath.find("/colorcodes/") == std::string::npos || + filePath.find("../") != std::string::npos) + return; + if (fs::exists(filePath)) fs::remove(filePath); }