Skip to content

Commit

Permalink
Revert "Temp: Unbreak mainmenu security"
Browse files Browse the repository at this point in the history
This reverts commit d8ff60e.
  • Loading branch information
grorp committed Nov 21, 2024
1 parent 30f4988 commit 6a5603f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/script/scripting_mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,26 @@ void MainMenuScripting::registerLuaClasses(lua_State *L, int top)

bool MainMenuScripting::mayModifyPath(const std::string &path)
{
return true;
if (fs::PathStartsWith(path, fs::TempPath()))
return true;

std::string path_user = fs::RemoveRelativePathComponents(porting::path_user);

if (fs::PathStartsWith(path, path_user + DIR_DELIM "client"))
return true;
if (fs::PathStartsWith(path, path_user + DIR_DELIM "games"))
return true;
if (fs::PathStartsWith(path, path_user + DIR_DELIM "mods"))
return true;
if (fs::PathStartsWith(path, path_user + DIR_DELIM "textures"))
return true;
if (fs::PathStartsWith(path, path_user + DIR_DELIM "worlds"))
return true;

if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_cache)))
return true;

return false;
}

bool MainMenuScripting::checkPathAccess(const std::string &abs_path, bool write_required,
Expand Down

0 comments on commit 6a5603f

Please sign in to comment.