upgrade core add header check and incrace upload speed
This commit is contained in:
+26
-1
@@ -2,6 +2,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include "Export.h"
|
||||
#include "DateTime.h"
|
||||
|
||||
@@ -35,6 +36,11 @@ constexpr auto G_ERROR_PAGE = R"(
|
||||
|
||||
// inline constexpr std::string_view G_HTTP_STD_WEEK[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
|
||||
namespace Json
|
||||
{
|
||||
class Value;
|
||||
}
|
||||
|
||||
namespace uns
|
||||
{
|
||||
enum HTTPMethod
|
||||
@@ -65,6 +71,8 @@ namespace uns
|
||||
inline constexpr std::string_view resh_acma = "Access-Control-Max-Age";
|
||||
};
|
||||
|
||||
inline constexpr auto url_all = R"(/[\s\S]*)";
|
||||
|
||||
using POSTArgs = std::map<std::string, std::string>;
|
||||
|
||||
std::string UNSWSC_DLL_EXPORT EncodeErrorPage(int code);
|
||||
@@ -93,6 +101,23 @@ namespace uns
|
||||
std::string UNSWSC_DLL_EXPORT ToLower(const std::string& s);
|
||||
|
||||
std::string UNSWSC_DLL_EXPORT CalculateFileHashSHA256(const std::string& file);
|
||||
|
||||
Json::Value UNSWSC_DLL_EXPORT SafeJsonDecode(const std::string& str);
|
||||
|
||||
template <typename T, typename CharT = char>
|
||||
std::optional<T> UNSWSC_DLL_EXPORT SafeStoX(const std::basic_string<CharT>& str, std::size_t* pos = nullptr, int base = 10);
|
||||
template <typename T, typename CharT = char>
|
||||
std::optional<T> UNSWSC_DLL_EXPORT SafeStoX(std::basic_string_view<CharT> str, std::size_t* pos = nullptr, int base = 10);
|
||||
template <typename T, typename CharT>
|
||||
inline std::optional<T> SafeStoX(const CharT* str, std::size_t* pos = nullptr, int base = 10)
|
||||
{
|
||||
#if defined(__cpp_char8_t)
|
||||
if constexpr (std::is_same_v<CharT, char8_t>)
|
||||
return SafeStoX<T>(std::basic_string<char>(reinterpret_cast<const char*>(str)), pos, base); // 只有 u8"..." (char8_t) 强制转为 char 版本的 SafeStoX 处理
|
||||
else
|
||||
#endif
|
||||
return SafeStoX<T>(std::basic_string<CharT>(str), pos, base); // 普通 "..." (char) 和 L"..." (wchar_t) 保持各自类型,构造对应的 basic_string
|
||||
}
|
||||
}
|
||||
|
||||
namespace secure
|
||||
@@ -103,7 +128,7 @@ namespace uns
|
||||
* @param requested_path 客户端传入的、解码后的目标子路径
|
||||
* @return true 安全(在沙盒内);false 不安全(企图穿越或路径非法)
|
||||
*/
|
||||
bool IsSafePath(const std::string& safe_path, const std::string& requested_path);
|
||||
bool IsSafePath(const std::string& safe_path, const std::string& requested_path);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user