mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
Remove deprecated code
This commit is contained in:
parent
cfac61e55b
commit
e972ec5a22
@ -294,8 +294,8 @@ void RtspUrl::setup(bool is_ssl, const string &url, const string &user, const st
|
|||||||
splitUrl(ip, ip, port);
|
splitUrl(ip, ip, port);
|
||||||
|
|
||||||
_url = std::move(url);
|
_url = std::move(url);
|
||||||
_user = strCoding::UrlDecode(std::move(user));
|
_user = strCoding::UrlDecodeComponent(user);
|
||||||
_passwd = strCoding::UrlDecode(std::move(passwd));
|
_passwd = strCoding::UrlDecodeComponent(passwd);
|
||||||
_host = std::move(ip);
|
_host = std::move(ip);
|
||||||
_port = port;
|
_port = port;
|
||||||
_is_ssl = is_ssl;
|
_is_ssl = is_ssl;
|
||||||
|
@ -53,22 +53,6 @@ char HexStrToBin(const char *str) {
|
|||||||
return (high << 4) | low;
|
return (high << 4) | low;
|
||||||
}
|
}
|
||||||
|
|
||||||
string strCoding::UrlEncode(const string &str) {
|
|
||||||
string out;
|
|
||||||
size_t len = str.size();
|
|
||||||
for (size_t i = 0; i < len; ++i) {
|
|
||||||
char ch = str[i];
|
|
||||||
if (isalnum((uint8_t) ch)) {
|
|
||||||
out.push_back(ch);
|
|
||||||
} else {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%%%X%X", (uint8_t) ch >> 4, (uint8_t) ch & 0x0F);
|
|
||||||
out.append(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
string strCoding::UrlEncodePath(const string &str) {
|
string strCoding::UrlEncodePath(const string &str) {
|
||||||
const char *dont_escape = "!#&'*+:=?@/._-$,;~()";
|
const char *dont_escape = "!#&'*+:=?@/._-$,;~()";
|
||||||
string out;
|
string out;
|
||||||
@ -103,32 +87,6 @@ string strCoding::UrlEncodeComponent(const string &str) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
string strCoding::UrlDecode(const string &str) {
|
|
||||||
string output;
|
|
||||||
size_t i = 0, len = str.length();
|
|
||||||
while (i < len) {
|
|
||||||
if (str[i] == '%') {
|
|
||||||
if (i + 3 > len) {
|
|
||||||
// %后面必须还有两个字节才会反转义
|
|
||||||
output.append(str, i, len - i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
char ch = HexStrToBin(&(str[i + 1]));
|
|
||||||
if (ch == -1) {
|
|
||||||
// %后面两个字节不是16进制字符串,转义失败;直接拼接3个原始字符
|
|
||||||
output.append(str, i, 3);
|
|
||||||
} else {
|
|
||||||
output += ch;
|
|
||||||
}
|
|
||||||
i += 3;
|
|
||||||
} else {
|
|
||||||
output += str[i];
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
string strCoding::UrlDecodePath(const string &str) {
|
string strCoding::UrlDecodePath(const string &str) {
|
||||||
const char *dont_unescape = "#$&+,/:;=?@";
|
const char *dont_unescape = "#$&+,/:;=?@";
|
||||||
string output;
|
string output;
|
||||||
@ -185,27 +143,6 @@ std::string strCoding::UrlDecodeComponent(const std::string &str) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include "Util/onceToken.h"
|
|
||||||
static toolkit::onceToken token([]() {
|
|
||||||
auto str0 = strCoding::UrlDecode(
|
|
||||||
"rtsp%3A%2F%2Fadmin%3AJm13317934%25jm%40111.47.84.69%3A554%2FStreaming%2FChannels%2F101%3Ftransportmode%3Dunicast%26amp%3Bprofile%3DProfile_1");
|
|
||||||
auto str1 = strCoding::UrlDecode("%j1"); // 测试%后面两个字节不是16进制字符串
|
|
||||||
auto str2 = strCoding::UrlDecode("%a"); // 测试%后面字节数不够
|
|
||||||
auto str3 = strCoding::UrlDecode("%"); // 测试只有%
|
|
||||||
auto str4 = strCoding::UrlDecode("%%%"); // 测试多个%
|
|
||||||
auto str5 = strCoding::UrlDecode("%%%%40"); // 测试多个非法%后恢复正常解析
|
|
||||||
auto str6 = strCoding::UrlDecode("Jm13317934%jm"); // 测试多个非法%后恢复正常解析
|
|
||||||
cout << str0 << endl;
|
|
||||||
cout << str1 << endl;
|
|
||||||
cout << str2 << endl;
|
|
||||||
cout << str3 << endl;
|
|
||||||
cout << str4 << endl;
|
|
||||||
cout << str5 << endl;
|
|
||||||
cout << str6 << endl;
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////windows专用///////////////////////////////////
|
///////////////////////////////windows专用///////////////////////////////////
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
void UnicodeToGB2312(char* pOut, wchar_t uData)
|
void UnicodeToGB2312(char* pOut, wchar_t uData)
|
||||||
|
@ -18,10 +18,8 @@ namespace mediakit {
|
|||||||
|
|
||||||
class strCoding {
|
class strCoding {
|
||||||
public:
|
public:
|
||||||
[[deprecated]] static std::string UrlEncode(const std::string &str); //url utf8编码, deprecated
|
|
||||||
static std::string UrlEncodePath(const std::string &str); //url路径 utf8编码
|
static std::string UrlEncodePath(const std::string &str); //url路径 utf8编码
|
||||||
static std::string UrlEncodeComponent(const std::string &str); // url参数 utf8编码
|
static std::string UrlEncodeComponent(const std::string &str); // url参数 utf8编码
|
||||||
[[deprecated]] static std::string UrlDecode(const std::string &str); //url utf8解码, deprecated
|
|
||||||
static std::string UrlDecodePath(const std::string &str); //url路径 utf8解码
|
static std::string UrlDecodePath(const std::string &str); //url路径 utf8解码
|
||||||
static std::string UrlDecodeComponent(const std::string &str); // url参数 utf8解码
|
static std::string UrlDecodeComponent(const std::string &str); // url参数 utf8解码
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -683,18 +683,6 @@ void HttpSession::sendResponse(int code,
|
|||||||
AsyncSender::onSocketFlushed(data);
|
AsyncSender::onSocketFlushed(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
string HttpSession::urlDecode(const string &str) {
|
|
||||||
auto ret = strCoding::UrlDecode(str);
|
|
||||||
#ifdef _WIN32
|
|
||||||
GET_CONFIG(string, charSet, Http::kCharSet);
|
|
||||||
bool isGb2312 = !strcasecmp(charSet.data(), "gb2312");
|
|
||||||
if (isGb2312) {
|
|
||||||
ret = strCoding::UTF8ToGB2312(ret);
|
|
||||||
}
|
|
||||||
#endif // _WIN32
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
string HttpSession::urlDecodePath(const string &str) {
|
string HttpSession::urlDecodePath(const string &str) {
|
||||||
auto ret = strCoding::UrlDecodePath(str);
|
auto ret = strCoding::UrlDecodePath(str);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -44,7 +44,6 @@ public:
|
|||||||
void onRecv(const toolkit::Buffer::Ptr &) override;
|
void onRecv(const toolkit::Buffer::Ptr &) override;
|
||||||
void onError(const toolkit::SockException &err) override;
|
void onError(const toolkit::SockException &err) override;
|
||||||
void onManager() override;
|
void onManager() override;
|
||||||
[[deprecated]] static std::string urlDecode(const std::string &str);
|
|
||||||
static std::string urlDecodePath(const std::string &str);
|
static std::string urlDecodePath(const std::string &str);
|
||||||
static std::string urlDecodeComponent(const std::string &str);
|
static std::string urlDecodeComponent(const std::string &str);
|
||||||
void setTimeoutSec(size_t second);
|
void setTimeoutSec(size_t second);
|
||||||
|
Loading…
Reference in New Issue
Block a user