Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
solo
Commits
593e7ffa
Commit
593e7ffa
authored
Apr 04, 2016
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12091
parent
044e27c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+6
-5
src/main/java/org/b3log/solo/service/CommentQueryService.java
...main/java/org/b3log/solo/service/CommentQueryService.java
+7
-2
No files found.
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
593e7ffa
...
@@ -20,6 +20,7 @@ import java.net.URL;
...
@@ -20,6 +20,7 @@ import java.net.URL;
import
java.util.Date
;
import
java.util.Date
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
...
@@ -55,7 +56,7 @@ import org.jsoup.safety.Whitelist;
...
@@ -55,7 +56,7 @@ import org.jsoup.safety.Whitelist;
* Comment management service.
* Comment management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.
1.8, Dec 29, 2015
* @version 1.2.
2.8, Apr 4, 2016
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -333,7 +334,7 @@ public class CommentMgmtService {
...
@@ -333,7 +334,7 @@ public class CommentMgmtService {
final
String
commentURL
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_URL
);
final
String
commentURL
=
requestJSONObject
.
optString
(
Comment
.
COMMENT_URL
);
if
(!
Strings
.
isURL
(
commentURL
))
{
if
(!
Strings
.
isURL
(
commentURL
)
||
StringUtils
.
contains
(
commentURL
,
"<"
)
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Comment URL is invalid[{0}]"
,
commentURL
);
LOGGER
.
log
(
Level
.
WARN
,
"Comment URL is invalid[{0}]"
,
commentURL
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"urlInvalidLabel"
));
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"urlInvalidLabel"
));
...
@@ -354,7 +355,7 @@ public class CommentMgmtService {
...
@@ -354,7 +355,7 @@ public class CommentMgmtService {
// name XSS process
// name XSS process
commentName
=
Jsoup
.
clean
(
commentName
,
Whitelist
.
none
());
commentName
=
Jsoup
.
clean
(
commentName
,
Whitelist
.
none
());
requestJSONObject
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
requestJSONObject
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
// content Markdown & XSS process
// content Markdown & XSS process
commentContent
=
Markdowns
.
toHTML
(
commentContent
);
commentContent
=
Markdowns
.
toHTML
(
commentContent
);
commentContent
=
Jsoup
.
clean
(
commentContent
,
Whitelist
.
relaxed
());
commentContent
=
Jsoup
.
clean
(
commentContent
,
Whitelist
.
relaxed
());
...
@@ -453,7 +454,7 @@ public class CommentMgmtService {
...
@@ -453,7 +454,7 @@ public class CommentMgmtService {
ret
.
put
(
Keys
.
OBJECT_ID
,
commentId
);
ret
.
put
(
Keys
.
OBJECT_ID
,
commentId
);
// Save comment sharp URL
// Save comment sharp URL
final
String
commentSharpURL
=
Comments
.
getCommentSharpURLForPage
(
page
,
commentId
);
final
String
commentSharpURL
=
Comments
.
getCommentSharpURLForPage
(
page
,
commentId
);
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
...
@@ -552,7 +553,7 @@ public class CommentMgmtService {
...
@@ -552,7 +553,7 @@ public class CommentMgmtService {
comment
.
put
(
Comment
.
COMMENT_DATE
,
date
);
comment
.
put
(
Comment
.
COMMENT_DATE
,
date
);
ret
.
put
(
Comment
.
COMMENT_DATE
,
DateFormatUtils
.
format
(
date
,
"yyyy-MM-dd HH:mm:ss"
));
ret
.
put
(
Comment
.
COMMENT_DATE
,
DateFormatUtils
.
format
(
date
,
"yyyy-MM-dd HH:mm:ss"
));
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_NAME
,
commentName
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
ret
.
put
(
Comment
.
COMMENT_CONTENT
,
commentContent
);
...
...
src/main/java/org/b3log/solo/service/CommentQueryService.java
View file @
593e7ffa
...
@@ -20,6 +20,7 @@ import java.util.Date;
...
@@ -20,6 +20,7 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
...
@@ -46,7 +47,7 @@ import org.json.JSONObject;
...
@@ -46,7 +47,7 @@ import org.json.JSONObject;
* Comment query service.
* Comment query service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
7, Dec 19, 2015
* @version 1.1.0.
8, Apr 4, 2016
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -227,7 +228,11 @@ public class CommentQueryService {
...
@@ -227,7 +228,11 @@ public class CommentQueryService {
for
(
final
JSONObject
comment
:
comments
)
{
for
(
final
JSONObject
comment
:
comments
)
{
comment
.
put
(
Comment
.
COMMENT_TIME
,
((
Date
)
comment
.
get
(
Comment
.
COMMENT_DATE
)).
getTime
());
comment
.
put
(
Comment
.
COMMENT_TIME
,
((
Date
)
comment
.
get
(
Comment
.
COMMENT_DATE
)).
getTime
());
comment
.
put
(
Comment
.
COMMENT_NAME
,
comment
.
getString
(
Comment
.
COMMENT_NAME
));
comment
.
put
(
Comment
.
COMMENT_NAME
,
comment
.
getString
(
Comment
.
COMMENT_NAME
));
comment
.
put
(
Comment
.
COMMENT_URL
,
comment
.
getString
(
Comment
.
COMMENT_URL
));
String
url
=
comment
.
getString
(
Comment
.
COMMENT_URL
);
if
(
StringUtils
.
contains
(
url
,
"<"
))
{
// legacy issue https://github.com/b3log/solo/issues/12091
url
=
""
;
}
comment
.
put
(
Comment
.
COMMENT_URL
,
url
);
comment
.
put
(
Common
.
IS_REPLY
,
false
);
// Assumes this comment is not a reply
comment
.
put
(
Common
.
IS_REPLY
,
false
);
// Assumes this comment is not a reply
final
String
email
=
comment
.
optString
(
Comment
.
COMMENT_EMAIL
);
final
String
email
=
comment
.
optString
(
Comment
.
COMMENT_EMAIL
);
...
...
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