Sanitize the build info report to blank out the user's name
This report is intended for submission in bug reports, so it makes sense to avoid the user's name for privacy concerns.
This commit is contained in:
parent
296f8b091b
commit
3bececed7c
5 changed files with 28 additions and 11 deletions
|
@ -464,12 +464,12 @@ std::string full_build_report()
|
|||
<< "Game paths\n"
|
||||
<< "==========\n"
|
||||
<< '\n'
|
||||
<< "Data dir: " << game_config::path << '\n'
|
||||
<< "User config dir: " << filesystem::get_user_config_dir() << '\n'
|
||||
<< "User data dir: " << filesystem::get_user_data_dir() << '\n'
|
||||
<< "Saves dir: " << filesystem::get_saves_dir() << '\n'
|
||||
<< "Add-ons dir: " << filesystem::get_addons_dir() << '\n'
|
||||
<< "Cache dir: " << filesystem::get_cache_dir() << '\n'
|
||||
<< "Data dir: " << filesystem::sanitize_path(game_config::path) << '\n'
|
||||
<< "User config dir: " << filesystem::sanitize_path(filesystem::get_user_config_dir()) << '\n'
|
||||
<< "User data dir: " << filesystem::sanitize_path(filesystem::get_user_data_dir()) << '\n'
|
||||
<< "Saves dir: " << filesystem::sanitize_path(filesystem::get_saves_dir()) << '\n'
|
||||
<< "Add-ons dir: " << filesystem::sanitize_path(filesystem::get_addons_dir()) << '\n'
|
||||
<< "Cache dir: " << filesystem::sanitize_path(filesystem::get_cache_dir()) << '\n'
|
||||
<< '\n'
|
||||
<< "Libraries\n"
|
||||
<< "=========\n"
|
||||
|
|
|
@ -228,6 +228,11 @@ std::string normalize_path(const std::string& path,
|
|||
bool normalize_separators = false,
|
||||
bool resolve_dot_entries = false);
|
||||
|
||||
/**
|
||||
* Sanitizes a path to remove references to the user's name.
|
||||
*/
|
||||
std::string sanitize_path(const std::string& path);
|
||||
|
||||
/**
|
||||
* Returns whether the path is the root of the file hierarchy.
|
||||
*
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <boost/system/windows_error.hpp>
|
||||
#include <boost/iostreams/device/file_descriptor.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <set>
|
||||
|
||||
using boost::uintmax_t;
|
||||
|
@ -1356,4 +1357,15 @@ std::string get_program_invocation(const std::string &program_name)
|
|||
return (path(game_config::wesnoth_program_dir) / real_program_name).string();
|
||||
}
|
||||
|
||||
std::string sanitize_path(const std::string& path) {
|
||||
#ifdef _WIN32
|
||||
const std::string user_name = getenv("USERNAME");
|
||||
#else
|
||||
const std::string user_name = getenv("USER");
|
||||
#endif
|
||||
std::string canonicalized = filesystem::normalize_path(path, true, false);
|
||||
boost::replace_all(canonicalized, user_name, "USER");
|
||||
return canonicalized;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -264,10 +264,10 @@ game_launcher::game_launcher(const commandline_options& cmdline_opts, const char
|
|||
load_data_->show_replay = true;
|
||||
|
||||
std::cerr
|
||||
<< "\nData directory: " << game_config::path
|
||||
<< "\nUser configuration directory: " << filesystem::get_user_config_dir()
|
||||
<< "\nUser data directory: " << filesystem::get_user_data_dir()
|
||||
<< "\nCache directory: " << filesystem::get_cache_dir()
|
||||
<< "\nData directory: " << filesystem::sanitize_path(game_config::path)
|
||||
<< "\nUser configuration directory: " << filesystem::sanitize_path(filesystem::get_user_config_dir())
|
||||
<< "\nUser data directory: " << filesystem::sanitize_path(filesystem::get_user_data_dir())
|
||||
<< "\nCache directory: " << filesystem::sanitize_path(filesystem::get_cache_dir())
|
||||
<< '\n';
|
||||
std::cerr << '\n';
|
||||
|
||||
|
|
|
@ -1140,7 +1140,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
if(!auto_dir.empty()) {
|
||||
std::cerr << "Automatically found a possible data directory at " << auto_dir << '\n';
|
||||
std::cerr << "Automatically found a possible data directory at " << filesystem::sanitize_path(auto_dir) << '\n';
|
||||
game_config::path = auto_dir;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue