Show newest comments first
This prevents new comments from not being displayed after a comment containing invalid html has been posted.
This commit is contained in:
parent
7068c84c6a
commit
3d282e163c
@ -49,10 +49,7 @@ import org.owasp.encoder.*;
|
|||||||
|
|
||||||
import static org.springframework.http.MediaType.ALL_VALUE;
|
import static org.springframework.http.MediaType.ALL_VALUE;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
|
|
||||||
@ -78,14 +75,13 @@ public class StoredXssComments extends AssignmentEndpoint {
|
|||||||
@RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE,consumes = ALL_VALUE)
|
@RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE,consumes = ALL_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Collection<Comment> retrieveComments() {
|
public Collection<Comment> retrieveComments() {
|
||||||
Collection<Comment> allComments = Lists.newArrayList();
|
List<Comment> allComments = Lists.newArrayList();
|
||||||
Collection<Comment> newComments = userComments.get(webSession.getUserName());
|
Collection<Comment> newComments = userComments.get(webSession.getUserName());
|
||||||
|
allComments.addAll(comments);
|
||||||
if (newComments != null) {
|
if (newComments != null) {
|
||||||
allComments.addAll(newComments);
|
allComments.addAll(newComments);
|
||||||
}
|
}
|
||||||
|
Collections.reverse(allComments);
|
||||||
allComments.addAll(comments);
|
|
||||||
|
|
||||||
return allComments;
|
return allComments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user