Skip to content

Commit

Permalink
WIP sanitizing build info to omit username
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Mar 11, 2018
1 parent 79c7c29 commit edc73ba
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/build_info.cpp
Expand Up @@ -454,6 +454,23 @@ std::string optional_features_report()
return o.str();
}

static std::string sanitize_path(const std::string& path) {
#ifdef _WIN32
const std::string user_profile = getenv("USERPROFILE");
#else
const std::string user_profile = getenv("HOME");
#endif
const std::string canonicalized = filesystem::normalize_path(path, true, false);
if(canonicalized.compare(0, user_profile.size(), user_profile) == 0) {
#ifdef _WIN32
return "%USERPROFILE%" + canonicalized.substr(user_profile.size());
#else
return "$HOME" + canonicalized.substr(user_profile.size());
#endif
}
return canonicalized;
}

std::string full_build_report()
{
std::ostringstream o;
Expand All @@ -464,12 +481,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: " << sanitize_path(game_config::path) << '\n'
<< "User config dir: " << sanitize_path(filesystem::get_user_config_dir()) << '\n'
<< "User data dir: " << sanitize_path(filesystem::get_user_data_dir()) << '\n'
<< "Saves dir: " << sanitize_path(filesystem::get_saves_dir()) << '\n'
<< "Add-ons dir: " << sanitize_path(filesystem::get_addons_dir()) << '\n'
<< "Cache dir: " << sanitize_path(filesystem::get_cache_dir()) << '\n'
<< '\n'
<< "Libraries\n"
<< "=========\n"
Expand Down

0 comments on commit edc73ba

Please sign in to comment.