Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
西魏
cms_sys
Commits
0abf45c4
Commit
0abf45c4
authored
May 13, 2020
by
铭飞
Committed by
Gitee
May 13, 2020
Browse files
Options
Browse Files
Download
Plain Diff
!232 添加XSS过滤器
Merge pull request !232 from 灰色DT/5.0.1
parents
8c1c762d
279f96ff
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
19 deletions
+16
-19
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+4
-6
WebConfig.java
src/main/java/net/mingsoft/config/WebConfig.java
+11
-12
search.htm
src/main/webapp/templets/1/default/search.htm
+1
-1
No files found.
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"
>
...
...
Write
Preview
Markdown
is supported
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