Merge branch 'release-0.6.6'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / CreateReplyPage.java
index 0b7e88f..2b12352 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.page.Page.Request.Method;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -58,8 +59,13 @@ public class CreateReplyPage extends SoneTemplatePage {
                if (request.getMethod() == Method.POST) {
                        Post post = webInterface.getCore().getPost(postId);
                        if (text.length() > 0) {
-                               Sone currentSone = getCurrentSone(request.getToadletContext());
-                               webInterface.getCore().createReply(currentSone, post, text);
+                               String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
+                               Sone sender = webInterface.getCore().getLocalSone(senderId, false);
+                               if (sender == null) {
+                                       sender = getCurrentSone(request.getToadletContext());
+                               }
+                               text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text);
+                               webInterface.getCore().createReply(sender, post, text);
                                throw new RedirectException(returnPage);
                        }
                        templateContext.set("errorTextEmpty", true);