Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert issue-#1511 #1523

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions company/static/company/js/md_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const olButton = document.querySelector('#list-ol');


preview.addEventListener('click', () => {
output(parse(textarea.value));
output(escapeHTML(parse(textarea.value)));

outputArea.classList.toggle('show');
previewMessage.classList.toggle('show');
Expand Down Expand Up @@ -302,10 +302,15 @@ function parse2(content) {
content = content.replace(unorderedSubList, '<ul class="list-disc pl-8">$&');
content = content.replace(orderedList, '<ol class="list-decimal pl-4">$&');
content = content.replace(orderedSubList, '<ol class="list-decimal pl-8">$&');
content = content.replace('</li>', '</li>'); // Ensure list item closing tag
content = content.replace('</li>', '</li><br>'); // Ensure list item closing tag

// Apply Tailwind CSS class to paragraphs
content = content.replace(/<p>(.*?)<\/p>/g, '<p class="text-base">$1</p>');

return '<div class="container mx-auto py-8">' + content + '</div>';
}
function escapeHTML(unsafeText) {
let div = document.createElement('div');
div.textContent = unsafeText;
return div.innerHTML;
}
Loading