diff --git a/api/add_comment.php b/api/add_comment.php index 33362a7..06538b7 100644 --- a/api/add_comment.php +++ b/api/add_comment.php @@ -99,6 +99,11 @@ try { exit; } + // Persist the trimmed text (not the raw client value) — matches update_comment.php + // and keeps stored comment_text free of leading whitespace that could shift a + // markdown-enabled comment's first line out of column 0 on reload. + $data['comment_text'] = $commentTextRaw; + // Never trust a client-supplied display name — always attribute the comment to // the authenticated session user. $data['user_name'] = $currentUser['display_name'] ?? $currentUser['username'] ?? 'User'; diff --git a/views/TicketView.php b/views/TicketView.php index 4b49a38..58ecf95 100644 --- a/views/TicketView.php +++ b/views/TicketView.php @@ -1219,7 +1219,7 @@ document.addEventListener('DOMContentLoaded', function () { if (typeof parseMarkdown === 'function') { list.querySelectorAll('.comment-text[data-markdown]').forEach(function (el) { if (!el.dataset.rendered) { - el.innerHTML = parseMarkdown(el.textContent); + el.innerHTML = parseMarkdown(el.textContent.trim()); el.dataset.rendered = '1'; } });