Skip to content

Commit fadcdbc

Browse files
committed
BUGFIX: Fixes an XSS issue in the comment form
This fixes an issue with the comment form which accepts unvalidated user input and can result in XSS exploitations. Resolves #17
1 parent 4a90bef commit fadcdbc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Classes/RobertLemke/Plugin/Blog/Controller/CommentController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public function createAction(NodeInterface $postNode, NodeTemplate $newComment)
6161
$this->throwStatus(400, 'Your comment was NOT created - it was too short.');
6262
}
6363

64+
$newComment->setProperty('text', filter_var($newComment->getProperty('text'), FILTER_SANITIZE_STRIPPED));
65+
$newComment->setProperty('author', filter_var($newComment->getProperty('author'), FILTER_SANITIZE_STRIPPED));
66+
$newComment->setProperty('emailAddress', filter_var($newComment->getProperty('emailAddress'), FILTER_SANITIZE_STRIPPED));
67+
6468
$commentNode = $postNode->getNode('comments')->createNodeFromTemplate($newComment, uniqid('comment-'));
6569
$commentNode->setProperty('spam', false);
6670
$commentNode->setProperty('datePublished', new \DateTime());

0 commit comments

Comments
 (0)