mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
bug-fix: fix urldecode in unsigned-char (#4424 #4423)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
This commit is contained in:
parent
2faa04da30
commit
acb12d7806
@ -38,14 +38,14 @@ void UnicodeToUTF8(char *pOut, const wchar_t *pText) {
|
||||
return;
|
||||
}
|
||||
|
||||
char HexCharToBin(char ch) {
|
||||
signed char HexCharToBin(char ch) {
|
||||
if (ch >= '0' && ch <= '9') return (char)(ch - '0');
|
||||
if (ch >= 'a' && ch <= 'f') return (char)(ch - 'a' + 10);
|
||||
if (ch >= 'A' && ch <= 'F') return (char)(ch - 'A' + 10);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char HexStrToBin(const char *str) {
|
||||
signed char HexStrToBin(const char *str) {
|
||||
auto high = HexCharToBin(str[0]);
|
||||
auto low = HexCharToBin(str[1]);
|
||||
if (high == -1 || low == -1) {
|
||||
@ -81,7 +81,7 @@ static string UrlDecodeCommon(const string &str,const char* dont_unescape){
|
||||
output.append(str, i, len - i);
|
||||
break;
|
||||
}
|
||||
char ch = HexStrToBin(&(str[i + 1]));
|
||||
signed char ch = HexStrToBin(&(str[i + 1]));
|
||||
if (ch == -1 || strchr(dont_unescape, (unsigned char)ch) != NULL) {
|
||||
// %后面两个字节不是16进制字符串,转义失败;或者转义出来可能会造成url包含非path部分,比如#?,说明提交的是非法拼接的url;直接拼接3个原始字符 [AUTO-TRANSLATED:7c734054]
|
||||
// The two bytes after % are not hexadecimal strings, the escape fails; or the escaped result may cause the url to contain non-path parts, such as #?, indicating that the submitted url is illegally spliced; directly splice the three original characters
|
||||
@ -142,7 +142,7 @@ std::string strCoding::UrlDecodeComponent(const std::string &str) {
|
||||
output.append(str, i, len - i);
|
||||
break;
|
||||
}
|
||||
char ch = HexStrToBin(&(str[i + 1]));
|
||||
signed char ch = HexStrToBin(&(str[i + 1]));
|
||||
if (ch == -1) {
|
||||
// %后面两个字节不是16进制字符串,转义失败;直接拼接3个原始字符 [AUTO-TRANSLATED:10e614a4]
|
||||
// The two bytes after % are not hexadecimal strings, the escape fails; directly splice the three original characters
|
||||
|
||||
Loading…
Reference in New Issue
Block a user