mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 06:09:09 +00:00
fs: Add allow_whitespace parameter to is_legal_user_file_name()
This is supposed to be false for the add-ons server, true (default) for saved games.
This commit is contained in:
parent
7f71a6e849
commit
e90067936d
@ -68,7 +68,7 @@ bool addon_filename_legal(const std::string& name)
|
||||
// Currently just a wrapper for filesystem::is_legal_user_file_name().
|
||||
// This is allowed to change in the future. Do not remove this wrapper.
|
||||
// I will hunt you down if you do.
|
||||
return filesystem::is_legal_user_file_name(name);
|
||||
return filesystem::is_legal_user_file_name(name, false);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -252,8 +252,11 @@ inline bool is_compressed_file(const std::string& filename) {
|
||||
* This is meant to be used for any files created by Wesnoth where user input
|
||||
* is required, including save files and add-on files for uploading to the
|
||||
* add-ons server.
|
||||
*
|
||||
* @param name File name to verify.
|
||||
* @param allow_whitespace Whether whitespace should be allowed.
|
||||
*/
|
||||
bool is_legal_user_file_name(const std::string& name);
|
||||
bool is_legal_user_file_name(const std::string& name, bool allow_whitespace = true);
|
||||
|
||||
struct file_tree_checksum
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ static lg::log_domain log_filesystem("filesystem");
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
bool is_legal_user_file_name(const std::string& name)
|
||||
bool is_legal_user_file_name(const std::string& name, bool allow_whitespace)
|
||||
{
|
||||
//
|
||||
// IMPORTANT NOTE:
|
||||
@ -77,10 +77,11 @@ bool is_legal_user_file_name(const std::string& name)
|
||||
return false; // name is an invalid UTF-8 sequence
|
||||
}
|
||||
|
||||
return name_ucs4.end() == std::find_if(name_ucs4.begin(), name_ucs4.end(), [](char32_t c)
|
||||
return name_ucs4.end() == std::find_if(name_ucs4.begin(), name_ucs4.end(), [=](char32_t c)
|
||||
{
|
||||
switch(c) {
|
||||
case ' ':
|
||||
return !allow_whitespace;
|
||||
case '"':
|
||||
case '*':
|
||||
case '/':
|
||||
|
Loading…
x
Reference in New Issue
Block a user