mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-12 19:57:02 +08:00
(RIN forum) added hotfix 3 by ce20fdf2 from https://cs.rin.ru/forum/viewtopic.php?p=2921215#p2921215
* + added missing implementation of (de)sanitize_string when NO_DISK_WRITE is defined which this fixes compilation of lobby_connect * + check for empty string in (de)sanitize_file_name() before accessing its items
This commit is contained in:
parent
ad9dfb2bd1
commit
b01a7ee116
@ -174,6 +174,16 @@ bool Local_Storage::save_screenshot(std::string const& image_path, uint8_t* img_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Local_Storage::sanitize_string(std::string name)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Local_Storage::desanitize_string(std::string name)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
|
|
||||||
@ -457,6 +467,8 @@ static std::string replace_with(std::string s, std::string const &old, const cha
|
|||||||
|
|
||||||
static std::string sanitize_file_name(std::string name)
|
static std::string sanitize_file_name(std::string name)
|
||||||
{
|
{
|
||||||
|
if (name.empty()) return name;
|
||||||
|
|
||||||
//I'm not sure all of these are necessary but just to be sure
|
//I'm not sure all of these are necessary but just to be sure
|
||||||
if (name[0] == '.' && name.size() > 2 && (name[1] == '\\' || name[1] == '/')) name.erase(0, 2);
|
if (name[0] == '.' && name.size() > 2 && (name[1] == '\\' || name[1] == '/')) name.erase(0, 2);
|
||||||
|
|
||||||
@ -478,6 +490,8 @@ static std::string sanitize_file_name(std::string name)
|
|||||||
|
|
||||||
static std::string desanitize_file_name(std::string name)
|
static std::string desanitize_file_name(std::string name)
|
||||||
{
|
{
|
||||||
|
if (name.empty()) return name;
|
||||||
|
|
||||||
//I'm not sure all of these are necessary but just to be sure
|
//I'm not sure all of these are necessary but just to be sure
|
||||||
name = replace_with(name, ".SLASH.", "/");
|
name = replace_with(name, ".SLASH.", "/");
|
||||||
name = replace_with(name, ".B_SLASH.", "\\");
|
name = replace_with(name, ".B_SLASH.", "\\");
|
||||||
@ -807,8 +821,7 @@ std::string Local_Storage::load_image_resized(std::string const& image_path, std
|
|||||||
resized_image = std::string(resized_img, resolution * resolution * 4);
|
resized_image = std::string(resized_img, resolution * resolution * 4);
|
||||||
stbi_image_free(img);
|
stbi_image_free(img);
|
||||||
}
|
}
|
||||||
}
|
} else if (image_data.length() > 0) {
|
||||||
else if (image_data.length() > 0) {
|
|
||||||
stbir_resize_uint8((unsigned char*)image_data.c_str(), 184, 184, NULL, (unsigned char*)resized_img, resolution, resolution, NULL, 4);
|
stbir_resize_uint8((unsigned char*)image_data.c_str(), 184, 184, NULL, (unsigned char*)resized_img, resolution, resolution, NULL, 4);
|
||||||
resized_image = std::string(resized_img, resolution * resolution * 4);
|
resized_image = std::string(resized_img, resolution * resolution * 4);
|
||||||
}
|
}
|
||||||
@ -827,4 +840,14 @@ bool Local_Storage::save_screenshot(std::string const& image_path, uint8_t* img_
|
|||||||
return stbi_write_png(screenshot_path.c_str(), width, height, channels, img_ptr, 0) == 1;
|
return stbi_write_png(screenshot_path.c_str(), width, height, channels, img_ptr, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Local_Storage::sanitize_string(std::string name)
|
||||||
|
{
|
||||||
|
return sanitize_file_name(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Local_Storage::desanitize_string(std::string name)
|
||||||
|
{
|
||||||
|
return desanitize_file_name(name);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,6 +87,9 @@ public:
|
|||||||
std::vector<image_pixel_t> load_image(std::string const& image_path);
|
std::vector<image_pixel_t> load_image(std::string const& image_path);
|
||||||
static std::string load_image_resized(std::string const& image_path, std::string const& image_data, int resolution);
|
static std::string load_image_resized(std::string const& image_path, std::string const& image_data, int resolution);
|
||||||
bool save_screenshot(std::string const& image_path, uint8_t* img_ptr, int32_t width, int32_t height, int32_t channels);
|
bool save_screenshot(std::string const& image_path, uint8_t* img_ptr, int32_t width, int32_t height, int32_t channels);
|
||||||
|
|
||||||
|
static std::string sanitize_string(std::string name);
|
||||||
|
static std::string desanitize_string(std::string name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -213,6 +213,7 @@ public:
|
|||||||
|
|
||||||
//warn people who use local save
|
//warn people who use local save
|
||||||
bool warn_local_save = false;
|
bool warn_local_save = false;
|
||||||
|
std::string local_save;
|
||||||
|
|
||||||
//steamhttp external download support
|
//steamhttp external download support
|
||||||
bool http_online = false;
|
bool http_online = false;
|
||||||
|
@ -469,6 +469,11 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||||||
settings_client->http_online = steamhttp_online_mode;
|
settings_client->http_online = steamhttp_online_mode;
|
||||||
settings_server->http_online = steamhttp_online_mode;
|
settings_server->http_online = steamhttp_online_mode;
|
||||||
|
|
||||||
|
if (local_save) {
|
||||||
|
settings_client->local_save = save_path;
|
||||||
|
settings_server->local_save = save_path;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";
|
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";
|
||||||
std::ifstream input( utf8_decode(dlc_config_path) );
|
std::ifstream input( utf8_decode(dlc_config_path) );
|
||||||
|
@ -127,7 +127,13 @@ struct Avatar_Numbers add_friend_avatars(CSteamID id)
|
|||||||
if (i == 0) file_name = "account_avatar.png";
|
if (i == 0) file_name = "account_avatar.png";
|
||||||
if (i == 1) file_name = "account_avatar.jpg";
|
if (i == 1) file_name = "account_avatar.jpg";
|
||||||
if (i == 2) file_name = "account_avatar.jpeg";
|
if (i == 2) file_name = "account_avatar.jpeg";
|
||||||
|
|
||||||
|
if (settings->local_save.length() > 0) {
|
||||||
|
file_path = settings->local_save + "/settings/" + file_name;
|
||||||
|
} else {
|
||||||
file_path = Local_Storage::get_user_appdata_path() + "/settings/" + file_name;
|
file_path = Local_Storage::get_user_appdata_path() + "/settings/" + file_name;
|
||||||
|
}
|
||||||
|
|
||||||
file_size = file_size_(file_path);
|
file_size = file_size_(file_path);
|
||||||
if (file_size) break;
|
if (file_size) break;
|
||||||
}
|
}
|
||||||
@ -165,7 +171,13 @@ struct Avatar_Numbers add_friend_avatars(CSteamID id)
|
|||||||
if (i == 0) file_name = "account_avatar_default.png";
|
if (i == 0) file_name = "account_avatar_default.png";
|
||||||
if (i == 1) file_name = "account_avatar_default.jpg";
|
if (i == 1) file_name = "account_avatar_default.jpg";
|
||||||
if (i == 2) file_name = "account_avatar_default.jpeg";
|
if (i == 2) file_name = "account_avatar_default.jpeg";
|
||||||
|
|
||||||
|
if (settings->local_save.length() > 0) {
|
||||||
|
file_path = settings->local_save + "/settings/" + file_name;
|
||||||
|
} else {
|
||||||
file_path = Local_Storage::get_user_appdata_path() + "/settings/" + file_name;
|
file_path = Local_Storage::get_user_appdata_path() + "/settings/" + file_name;
|
||||||
|
}
|
||||||
|
|
||||||
file_size = file_size_(file_path);
|
file_size = file_size_(file_path);
|
||||||
if (file_size) break;
|
if (file_size) break;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
|
|||||||
struct Steam_Http_Request request;
|
struct Steam_Http_Request request;
|
||||||
if (url_index) {
|
if (url_index) {
|
||||||
if (url[url.size() - 1] == '/') url += "index.html";
|
if (url[url.size() - 1] == '/') url += "index.html";
|
||||||
std::string file_path = Local_Storage::get_game_settings_path() + "http/" + url.substr(url_index);
|
std::string file_path = Local_Storage::get_game_settings_path() + "http/" + Local_Storage::sanitize_string(url.substr(url_index));
|
||||||
unsigned long long file_size = file_size_(file_path);
|
unsigned long long file_size = file_size_(file_path);
|
||||||
if (file_size) {
|
if (file_size) {
|
||||||
request.response.resize(file_size);
|
request.response.resize(file_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user