#include "addon/validation.hpp"
#include "config.hpp"
#include "filesystem.hpp"
#include "gettext.hpp"
#include "hash.hpp"
#include <algorithm>
#include <array>
#include <boost/algorithm/string.hpp>
Go to the source code of this file.
Functions | |
bool | addon_name_legal (const std::string &name) |
Checks whether an add-on id/name is legal or not. More... | |
bool | addon_filename_legal (const std::string &name) |
Checks whether an add-on file name is legal or not. More... | |
bool | check_names_legal (const config &dir, std::vector< std::string > *badlist) |
Scans an add-on archive for illegal names. More... | |
bool | check_case_insensitive_duplicates (const config &dir, std::vector< std::string > *badlist) |
Scans an add-on archive for case-conflicts. More... | |
ADDON_TYPE | get_addon_type (const std::string &str) |
std::string | get_addon_type_string (ADDON_TYPE type) |
bool | needs_escaping (char c) |
std::string | encode_binary (const std::string &str) |
std::string | unencode_binary (const std::string &str) |
static std::string | file_hash_raw (const config &file) |
std::string | file_hash (const config &file) |
bool | comp_file_hash (const config &file_a, const config &file_b) |
void | write_hashlist (config &hashlist, const config &data) |
bool | contains_hashlist (const config &from, const config &to) |
static bool | write_difference (config &pack, const config &from, const config &to, bool with_content) |
Surround with [dir][/dir]. More... | |
void | make_updatepack (config &pack, const config &from, const config &to) |
&from, &to are the top directories of their structures; addlist/removelist tag is treated as [dir] More... | |
std::string | addon_check_status_desc (unsigned int code) |
std::string | translated_addon_check_status (unsigned int code) |
Variables | |
const unsigned short | default_campaignd_port = 15019 |
Default port number for the addon server. More... | |
std::string addon_check_status_desc | ( | unsigned int | code | ) |
Definition at line 378 of file validation.cpp.
References AUTH_TYPE_MISMATCH, BAD_DELTA, BAD_FEEDBACK_TOPIC_ID, BAD_NAME, BAD_TYPE, DENIED, EMPTY_PACK, FEEDBACK_TOPIC_ID_NOT_FOUND, FILENAME_CASE_CONFLICT, ILLEGAL_FILENAME, INVALID_UTF8_ATTRIBUTE, INVALID_UTF8_NAME, N_, NAME_HAS_MARKUP, NO_AUTHOR, NO_DESCRIPTION, NO_EMAIL, NO_PASSPHRASE, NO_TITLE, NO_VERSION, SERVER_ADDONS_LIST, SERVER_DELTA_NO_VERSIONS, SERVER_FORUM_AUTH_DISABLED, SERVER_READ_ONLY, SERVER_UNSPECIFIED, SUCCESS, TITLE_HAS_MARKUP, UNAUTHORIZED, UNEXPECTED_DELTA, USER_DOES_NOT_EXIST, and VERSION_NOT_INCREMENTED.
Referenced by addon_check_status_desc(), campaignd::server::handle_upload(), and translated_addon_check_status().
bool addon_filename_legal | ( | const std::string & | name | ) |
Checks whether an add-on file name is legal or not.
Definition at line 66 of file validation.cpp.
References filesystem::is_legal_user_file_name().
Referenced by BOOST_AUTO_TEST_CASE(), editor::context_manager::change_addon_id(), and editor::initialize_addon().
bool addon_name_legal | ( | const std::string & | name | ) |
Checks whether an add-on id/name is legal or not.
Definition at line 56 of file validation.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), addons_client::upload_addon(), and campaignd::server::validate_addon().
bool check_case_insensitive_duplicates | ( | const config & | dir, |
std::vector< std::string > * | badlist = nullptr |
||
) |
Scans an add-on archive for case-conflicts.
Case conflicts may cause trouble on case-insensitive filesystems.
dir | The WML container for the root [dir] node where the search should begin. |
badlist | If provided and not null, any case conflicts encountered will be added to this list. This also makes the archive scan more thorough instead of returning on the first conflict encountered. |
Definition at line 175 of file validation.cpp.
Referenced by addons_client::install_addon(), and addons_client::upload_addon().
bool check_names_legal | ( | const config & | dir, |
std::vector< std::string > * | badlist = nullptr |
||
) |
Scans an add-on archive for illegal names.
dir | The WML container for the root [dir] node where the search should begin. |
badlist | If provided and not null, any illegal names encountered will be added to this list. This also makes the archive scan more thorough instead of returning on the first illegal name encountered. |
Definition at line 166 of file validation.cpp.
Referenced by addons_client::install_addon(), and addons_client::upload_addon().
Definition at line 267 of file validation.cpp.
References file_hash().
Referenced by contains_hashlist(), and write_difference().
Definition at line 288 of file validation.cpp.
References config::child_range(), comp_file_hash(), d, f, and config::find_child().
Referenced by addons_client::upload_addon().
std::string encode_binary | ( | const std::string & | str | ) |
Definition at line 218 of file validation.cpp.
References n, and needs_escaping().
Referenced by archive_file(), and BOOST_AUTO_TEST_CASE().
std::string file_hash | ( | const config & | file | ) |
Definition at line 258 of file validation.cpp.
References file_hash_raw().
Referenced by comp_file_hash(), and write_difference().
|
static |
Definition at line 253 of file validation.cpp.
References utils::md5::base64_digest().
Referenced by file_hash(), and write_hashlist().
ADDON_TYPE get_addon_type | ( | const std::string & | str | ) |
Definition at line 180 of file validation.cpp.
References ADDON_TYPES_COUNT, and ADDON_UNKNOWN.
Referenced by addon_info::read(), and campaignd::server::validate_addon().
std::string get_addon_type_string | ( | ADDON_TYPE | type | ) |
Definition at line 196 of file validation.cpp.
References ADDON_TYPES_COUNT.
Referenced by addon_info::write(), and addon_info::write_minimal().
&from, &to are the top directories of their structures; addlist/removelist tag is treated as [dir]
Does it worth it to archive and write the pack on the fly using config_writer? TODO: clientside verification?
Definition at line 370 of file validation.cpp.
References config::add_child(), and write_difference().
Referenced by campaignd::server::handle_upload(), and addons_client::upload_addon().
bool needs_escaping | ( | char | c | ) |
std::string translated_addon_check_status | ( | unsigned int | code | ) |
Definition at line 540 of file validation.cpp.
References _(), and addon_check_status_desc().
Referenced by translated_addon_check_status(), and addons_client::update_last_error().
std::string unencode_binary | ( | const std::string & | str | ) |
Definition at line 236 of file validation.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), and unarchive_file().
|
static |
Surround with [dir][/dir].
Definition at line 321 of file validation.cpp.
References config::add_child(), config::child_range(), comp_file_hash(), d, f, file_hash(), and config::find_child().
Referenced by make_updatepack().
Definition at line 272 of file validation.cpp.
References config::add_child(), d, data, f, and file_hash_raw().
Referenced by campaignd::server::handle_upload(), and campaignd::server::load_config().
const unsigned short default_campaignd_port = 15019 |
Default port number for the addon server.
Definition at line 27 of file validation.cpp.
Referenced by addons_client::addons_client(), and campaignd::server::load_config().