Skip to content

Commit 07b7858

Browse files
committed
[ROL-2135] parse math answer to string.
1 parent 0d42c6d commit 07b7858

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/src/main/java/org/apache/roller/weblogger/ui/rendering/plugins/comments/MathCommentAuthenticator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class MathCommentAuthenticator implements CommentAuthenticator {
3737

3838
public String getHtml(HttpServletRequest request) {
3939

40-
String answer = "";
40+
int answer = 0;
4141

4242
HttpSession session = request.getSession(true);
4343
if (session.getAttribute("mathAnswer") == null) {
@@ -51,10 +51,12 @@ public String getHtml(HttpServletRequest request) {
5151
session.setAttribute("mathAnswer", sum);
5252
} else {
5353
// preserve user's answer
54-
answer = request.getParameter("answer");
55-
answer = (answer == null) ? "" : answer;
54+
String answerString = request.getParameter("answer");
55+
try {
56+
answer = Integer.parseInt(answerString);
57+
} catch (Throwable intentionallyIgnored) {}
5658
}
57-
59+
5860
// pull existing values out of session
5961
Integer value1o = (Integer)request.getSession().getAttribute("mathValue1");
6062
Integer value2o = (Integer)request.getSession().getAttribute("mathValue2");

0 commit comments

Comments
 (0)