mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
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).
This commit is contained in:
parent
f948e2c585
commit
3ce03d1c2a
6 changed files with 136 additions and 17 deletions
|
@ -746,3 +746,11 @@ inline irr::core::stringw utf8_to_stringw(const std::string &input)
|
|||
std::wstring str = utf8_to_wide(input);
|
||||
return irr::core::stringw(str.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the name of a new directory. This consists of two stages:
|
||||
* 1. Check for 'reserved filenames' that can't be used on some filesystems
|
||||
* and prefix them
|
||||
* 2. Remove 'unsafe' characters from the name by replacing them with '_'
|
||||
*/
|
||||
std::string sanitizeDirName(const std::string &str, const std::string &optional_prefix);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue