Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
795b4dbb
Commit
795b4dbb
authored
Aug 10, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复http文件服务器对特殊字符文件不兼容的bug:#1866
parent
099845b3
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
26 行删除
+19
-26
src/Http/HttpFileManager.cpp
+2
-1
src/Http/strCoding.cpp
+17
-25
没有找到文件。
src/Http/HttpFileManager.cpp
查看文件 @
795b4dbb
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "HttpSession.h"
#include "HttpSession.h"
#include "Record/HlsMediaSource.h"
#include "Record/HlsMediaSource.h"
#include "Common/Parser.h"
#include "Common/Parser.h"
#include "strCoding.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
toolkit
;
...
@@ -124,7 +125,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
...
@@ -124,7 +125,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
if
(
pDirent
->
d_name
[
0
]
==
'.'
)
{
if
(
pDirent
->
d_name
[
0
]
==
'.'
)
{
continue
;
continue
;
}
}
file_map
.
emplace
(
pDirent
->
d_name
,
std
::
make_pair
(
pDirent
->
d_name
,
strPathPrefix
+
"/"
+
pDirent
->
d_name
));
file_map
.
emplace
(
strCoding
::
UrlEncode
(
pDirent
->
d_name
)
,
std
::
make_pair
(
pDirent
->
d_name
,
strPathPrefix
+
"/"
+
pDirent
->
d_name
));
}
}
//如果是root目录,添加虚拟目录
//如果是root目录,添加虚拟目录
if
(
httpPath
==
"/"
)
{
if
(
httpPath
==
"/"
)
{
...
...
src/Http/strCoding.cpp
查看文件 @
795b4dbb
...
@@ -20,32 +20,30 @@ using namespace std;
...
@@ -20,32 +20,30 @@ using namespace std;
namespace
mediakit
{
namespace
mediakit
{
//////////////////////////通用///////////////////////
//////////////////////////通用///////////////////////
void
UTF8ToUnicode
(
wchar_t
*
pOut
,
const
char
*
pText
)
void
UTF8ToUnicode
(
wchar_t
*
pOut
,
const
char
*
pText
)
{
{
char
*
uchar
=
(
char
*
)
pOut
;
char
*
uchar
=
(
char
*
)
pOut
;
uchar
[
1
]
=
((
pText
[
0
]
&
0x0F
)
<<
4
)
+
((
pText
[
1
]
>>
2
)
&
0x0F
);
uchar
[
1
]
=
((
pText
[
0
]
&
0x0F
)
<<
4
)
+
((
pText
[
1
]
>>
2
)
&
0x0F
);
uchar
[
0
]
=
((
pText
[
1
]
&
0x03
)
<<
6
)
+
(
pText
[
2
]
&
0x3F
);
uchar
[
0
]
=
((
pText
[
1
]
&
0x03
)
<<
6
)
+
(
pText
[
2
]
&
0x3F
);
return
;
return
;
}
}
void
UnicodeToUTF8
(
char
*
pOut
,
const
wchar_t
*
pText
)
{
void
UnicodeToUTF8
(
char
*
pOut
,
const
wchar_t
*
pText
)
{
// 注意 WCHAR高低字的顺序,低字节在前,高字节在后
// 注意 WCHAR高低字的顺序,低字节在前,高字节在后
const
char
*
pchar
=
(
const
char
*
)
pText
;
const
char
*
pchar
=
(
const
char
*
)
pText
;
pOut
[
0
]
=
(
0xE0
|
((
pchar
[
1
]
&
0xF0
)
>>
4
));
pOut
[
0
]
=
(
0xE0
|
((
pchar
[
1
]
&
0xF0
)
>>
4
));
pOut
[
1
]
=
(
0x80
|
((
pchar
[
1
]
&
0x0F
)
<<
2
))
+
((
pchar
[
0
]
&
0xC0
)
>>
6
);
pOut
[
1
]
=
(
0x80
|
((
pchar
[
1
]
&
0x0F
)
<<
2
))
+
((
pchar
[
0
]
&
0xC0
)
>>
6
);
pOut
[
2
]
=
(
0x80
|
(
pchar
[
0
]
&
0x3F
));
pOut
[
2
]
=
(
0x80
|
(
pchar
[
0
]
&
0x3F
));
return
;
return
;
}
}
char
CharToInt
(
char
ch
)
char
CharToInt
(
char
ch
)
{
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
return
(
char
)
(
ch
-
'0'
);
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
);
if
(
ch
>=
'A'
&&
ch
<=
'F'
)
return
(
char
)
(
ch
-
'A'
+
10
);
if
(
ch
>=
'A'
&&
ch
<=
'F'
)
return
(
char
)(
ch
-
'A'
+
10
);
return
-
1
;
return
-
1
;
}
}
char
StrToBin
(
const
char
*
str
)
{
char
StrToBin
(
const
char
*
str
)
{
char
tempWord
[
2
];
char
tempWord
[
2
];
char
chn
;
char
chn
;
tempWord
[
0
]
=
CharToInt
(
str
[
0
]);
//make the B to 11 -- 00001011
tempWord
[
0
]
=
CharToInt
(
str
[
0
]);
//make the B to 11 -- 00001011
...
@@ -59,23 +57,24 @@ string strCoding::UrlEncode(const string &str) {
...
@@ -59,23 +57,24 @@ string strCoding::UrlEncode(const string &str) {
size_t
len
=
str
.
size
();
size_t
len
=
str
.
size
();
for
(
size_t
i
=
0
;
i
<
len
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
len
;
++
i
)
{
char
ch
=
str
[
i
];
char
ch
=
str
[
i
];
if
(
isalnum
((
uint8_t
)
ch
))
{
if
(
isalnum
((
uint8_t
)
ch
))
{
out
.
push_back
(
ch
);
out
.
push_back
(
ch
);
}
else
{
}
else
{
char
buf
[
4
];
char
buf
[
4
];
sprintf
(
buf
,
"%%%X%X"
,
(
uint8_t
)
ch
>>
4
,(
uint8_t
)
ch
&
0x0F
);
sprintf
(
buf
,
"%%%X%X"
,
(
uint8_t
)
ch
>>
4
,
(
uint8_t
)
ch
&
0x0F
);
out
.
append
(
buf
);
out
.
append
(
buf
);
}
}
}
}
return
out
;
return
out
;
}
}
string
strCoding
::
UrlDecode
(
const
string
&
str
)
{
string
strCoding
::
UrlDecode
(
const
string
&
str
)
{
string
output
=
""
;
string
output
;
char
tmp
[
2
];
char
tmp
[
2
];
size_t
i
=
0
,
len
=
str
.
length
();
size_t
i
=
0
,
len
=
str
.
length
();
while
(
i
<
len
)
{
while
(
i
<
len
)
{
if
(
str
[
i
]
==
'%'
)
{
if
(
str
[
i
]
==
'%'
)
{
if
(
i
>
len
-
3
)
{
if
(
i
>
len
-
3
)
{
//防止内存溢出
//防止内存溢出
break
;
break
;
}
}
...
@@ -83,9 +82,6 @@ string strCoding::UrlDecode(const string &str) {
...
@@ -83,9 +82,6 @@ string strCoding::UrlDecode(const string &str) {
tmp
[
1
]
=
str
[
i
+
2
];
tmp
[
1
]
=
str
[
i
+
2
];
output
+=
StrToBin
(
tmp
);
output
+=
StrToBin
(
tmp
);
i
=
i
+
3
;
i
=
i
+
3
;
}
else
if
(
str
[
i
]
==
'+'
)
{
output
+=
' '
;
i
++
;
}
else
{
}
else
{
output
+=
str
[
i
];
output
+=
str
[
i
];
i
++
;
i
++
;
...
@@ -94,7 +90,6 @@ string strCoding::UrlDecode(const string &str) {
...
@@ -94,7 +90,6 @@ string strCoding::UrlDecode(const string &str) {
return
output
;
return
output
;
}
}
///////////////////////////////windows专用///////////////////////////////////
///////////////////////////////windows专用///////////////////////////////////
#if defined(_WIN32)
#if defined(_WIN32)
void
UnicodeToGB2312
(
char
*
pOut
,
wchar_t
uData
)
void
UnicodeToGB2312
(
char
*
pOut
,
wchar_t
uData
)
...
@@ -169,7 +164,4 @@ string strCoding::GB2312ToUTF8(const string &str) {
...
@@ -169,7 +164,4 @@ string strCoding::GB2312ToUTF8(const string &str) {
}
}
#endif//defined(_WIN32)
#endif//defined(_WIN32)
}
/* namespace mediakit */
}
/* namespace mediakit */
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论