- Issue created by @purencool
- 🇮🇳India arunsahijpal
Hey @purencool,
could you please tell steps reproduce this issue. - 🇨🇦Canada jeremylichtman
The Xss:filter() error can only happen if the string being passed into it is null.
Looking at the code in burndown/src/Controller/TaskController.php(163):
public function addComment(Request $request) { // Get data from request (validated below). $ticket_id = $request->request->get('ticket_id'); $comment = $request->request->get('comment'); // Load the task. $task = Task::loadFromTicketId($ticket_id); if ($task === FALSE) { // Task doesn't exist; throw 404. throw new NotFoundHttpException(); } // Add comment to the log. $type = 'comment'; $filtered_comment = Xss::filter($comment); ...
This can only happen if "$comment = $request->request->get('comment');" is producing a null value.
This is called via a POST:
burndown.task_add_comment: path: '/burndown/api/task/add_comment' defaults: _controller: '\Drupal\burndown\Controller\TaskController::addComment' methods: [POST] requirements: _permission: 'burndown comment on task'
and the POST, in turn is called via burndown\js\burndown.task_edit.js.
// Posting a comment. $(once('postCommentAction','body')) .on('click', '.add_comment a.button', function (e) { // Do not follow the link. e.preventDefault(); e.stopPropagation(); // Post data. $.ajax({ url: "/burndown/api/task/add_comment", method :'POST', data: { ticket_id: $('#burndown_task_log').data('ticket-id'), comment: $('.add_comment .form-item-body textarea').val() }, success: function (result) { // On success, reload comments and clear the form. update_log('comment'); $('.add_comment .form-item-body textarea').val(''); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("Could not post comment."); } }); });
You may want to open the console log (and maybe try a js breakpoint) to see what is going on. This sounds like it could be browser-related though, rather than server-side.
- 🇦🇺Australia purencool
Thanks @jeremylichtman,
I will look into your frontend suggestion to see if what is causing the problem.
- 🇦🇺Australia purencool
It seems to be a html class issue. Claro is rendering the html class .form-item--body, while jQuery is looking for a .form-item-body class.
Code that fails.
$.ajax({ url: "/burndown/api/task/add_comment", method :'POST', data: { ticket_id: $('#burndown_task_log').data('ticket-id'), comment: $('.add_comment .form-item-body textarea').val() },
Code that works.
// Post data. $.ajax({ url: "/burndown/api/task/add_comment", method :'POST', data: { ticket_id: $('#burndown_task_log').data('ticket-id'), comment: $('.add_comment .form-item--body textarea').val() },
Possible solution could be.
data: { ticket_id: $('#burndown_task_log').data('ticket-id'), comment: $('.add_comment textarea').val() },
- 🇨🇦Canada jeremylichtman
Ah. You're using a different theme.
I think the correct solution is to push a custom class onto that field, and target that instead.
Note that there's probably other instances of this. The whole thing is full of AJAX calls of this sort, and it was built against the custom theme. I think I have an old todo somewhere regarding the possibility of this happening.
Automatically closed - issue fixed for 2 weeks with no activity.