diff options
author | Hugues Ross <hugues.ross@gmail.com> | 2020-07-28 13:16:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 19:16:57 +0200 |
commit | 3ce03d1c2a63d261c83f5962cd13212697f19472 (patch) | |
tree | f7c7db205866254865d18c711682c984c062b9cc /src/server.cpp | |
parent | f948e2c58570df6bc77226b6066fec5ed90051ee (diff) | |
download | minetest-3ce03d1c2a63d261c83f5962cd13212697f19472.tar.gz minetest-3ce03d1c2a63d261c83f5962cd13212697f19472.tar.bz2 minetest-3ce03d1c2a63d261c83f5962cd13212697f19472.zip |
Sanitize world directory names on create. Keep original name separate (#9432)
Blacklisted characters are replaced by '_' in the path. The display name is stored in world.mt, and duplicate file names are resolved by adding an incrementing suffix (_1, _2, _3, etc).
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index fe2bb3840..53ee8c444 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -356,8 +356,13 @@ void Server::init() infostream << "- game: " << m_gamespec.path << std::endl; // Create world if it doesn't exist - if (!loadGameConfAndInitWorld(m_path_world, m_gamespec)) - throw ServerError("Failed to initialize world"); + try { + loadGameConfAndInitWorld(m_path_world, + fs::GetFilenameFromPath(m_path_world.c_str()), + m_gamespec, false); + } catch (const BaseException &e) { + throw ServerError(std::string("Failed to initialize world: ") + e.what()); + } // Create emerge manager m_emerge = new EmergeManager(this); |