Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
MCMS
Commits
0abf45c4
Commit
0abf45c4
authored
May 13, 2020
by
铭飞
Committed by
Gitee
May 13, 2020
Browse files
!232 添加XSS过滤器
Merge pull request !232 from 灰色DT/5.0.1
parents
8c1c762d
279f96ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
0abf45c4
...
@@ -295,9 +295,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -295,9 +295,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 读取请求字段
// 读取请求字段
Map
<
String
,
String
[]>
field
=
request
.
getParameterMap
();
Map
<
String
,
Object
>
field
=
BasicUtil
.
assemblyRequestMap
();
// 文章字段集合
Map
<
String
,
Object
>
articleFieldName
=
new
HashMap
<
String
,
Object
>();
// 自定义字段集合
// 自定义字段集合
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
CategoryEntity
column
=
null
;
// 当前栏目
CategoryEntity
column
=
null
;
// 当前栏目
...
@@ -330,9 +328,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -330,9 +328,9 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
// 遍历取字段集合
// 遍历取字段集合
if
(
field
!=
null
)
{
if
(
field
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
[]
>
entry
:
field
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
field
.
entrySet
())
{
if
(
entry
!=
null
)
{
if
(
entry
!=
null
)
{
String
value
=
entry
.
getValue
()
[
0
]
;
// 处理由get方法请求中文乱码问题
String
value
=
entry
.
getValue
()
.
toString
()
;
// 处理由get方法请求中文乱码问题
if
(
ObjectUtil
.
isNull
(
value
))
{
if
(
ObjectUtil
.
isNull
(
value
))
{
continue
;
continue
;
}
}
...
@@ -380,7 +378,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
...
@@ -380,7 +378,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e1
)
{
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
e1
.
printStackTrace
();
}
}
Map
<
String
,
Object
>
searchMap
=
BasicUtil
.
assemblyRequestMap
()
;
Map
<
String
,
Object
>
searchMap
=
field
;
searchMap
.
forEach
((
k
,
v
)->{
searchMap
.
forEach
((
k
,
v
)->{
//sql注入过滤
//sql注入过滤
if
(
sqlFilter
(
v
.
toString
())){
if
(
sqlFilter
(
v
.
toString
())){
...
...
src/main/java/net/mingsoft/config/WebConfig.java
View file @
0abf45c4
...
@@ -89,18 +89,17 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -89,18 +89,17 @@ public class WebConfig implements WebMvcConfigurer {
beanTypeAutoProxyCreator
.
setInterceptorNames
(
"druidStatInterceptor"
);
beanTypeAutoProxyCreator
.
setInterceptorNames
(
"druidStatInterceptor"
);
return
beanTypeAutoProxyCreator
;
return
beanTypeAutoProxyCreator
;
}
}
// XSS过滤器
//XSS过滤器
// @Bean
@Bean
// public FilterRegistrationBean xssFilterRegistration() {
public
FilterRegistrationBean
xssFilterRegistration
()
{
// XSSEscapeFilter xssFilter = new XSSEscapeFilter();
XSSEscapeFilter
xssFilter
=
new
XSSEscapeFilter
();
// FilterRegistrationBean registration = new FilterRegistrationBean(xssFilter);
FilterRegistrationBean
registration
=
new
FilterRegistrationBean
(
xssFilter
);
// xssFilter.excludes.add(".*file/upload.do");
xssFilter
.
includes
.
add
(
".*/search.do"
);
// xssFilter.excludes.add(".*/jsp/editor.do");
registration
.
setName
(
"XSSFilter"
);
// xssFilter.excludes.add(".*/?(jpg|js|css|gif|png|ico)$");
registration
.
addUrlPatterns
(
"/*"
);
// xssFilter.excludes.add("/");
registration
.
setOrder
(
Ordered
.
HIGHEST_PRECEDENCE
);
// registration.addUrlPatterns("/*");
return
registration
;
// return registration;
}
// }
/**
/**
* RequestContextListener注册
* RequestContextListener注册
...
...
src/main/webapp/templets/1/default/search.htm
View file @
0abf45c4
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<div
class=
"ms-content-main-list"
id=
"ms-content-search"
>
<div
class=
"ms-content-main-list"
id=
"ms-content-search"
>
<div
class=
"ms-content-main-div"
>
<div
class=
"ms-content-main-div"
>
<div
class=
"ms-content-main-div-prompt"
>
您搜索的关键字
<div
class=
"ms-content-main-div-prompt"
>
您搜索的关键字
<span>
{ms:search.
basic
_title/}
</span>
<span>
{ms:search.
content
_title/}
</span>
<!-- 共7个结果 -->
<!-- 共7个结果 -->
</div>
</div>
<ul
class=
"ms-content-main-ul"
>
<ul
class=
"ms-content-main-ul"
>
...
@@ -55,12 +55,12 @@ new Vue({
...
@@ -55,12 +55,12 @@ new Vue({
pageNo
=
pageNo
-
1
==
0
?
1
:
pageNo
-
1
;
//上一页
pageNo
=
pageNo
-
1
==
0
?
1
:
pageNo
-
1
;
//上一页
}
}
window
.
location
.
href
=
"
{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo=
"
+
pageNo
;
window
.
location
.
href
=
"
{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo=
"
+
pageNo
;
window
.
event
.
returnValue
=
false
;
window
.
event
.
returnValue
=
false
;
},
},
//首页和尾页
//首页和尾页
indexAndLast
:
function
(
pageNo
){
indexAndLast
:
function
(
pageNo
){
window
.
location
.
href
=
"
{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo=
"
+
pageNo
;
window
.
location
.
href
=
"
{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo=
"
+
pageNo
;
window
.
event
.
returnValue
=
false
;
window
.
event
.
returnValue
=
false
;
},
},
},
},
})
})
...
@@ -68,4 +68,4 @@ new Vue({
...
@@ -68,4 +68,4 @@ new Vue({
$
(
'
.ms-content-main-page
'
).
remove
();
$
(
'
.ms-content-main-page
'
).
remove
();
$
(
'
.ms-content-main-ul
'
).
before
(
"
<div class='ms-content-main-div-nothing'>没找到相关记录</div>
"
)
$
(
'
.ms-content-main-ul
'
).
before
(
"
<div class='ms-content-main-div-nothing'>没找到相关记录</div>
"
)
}
}
</script>
</script>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment