diff --git a/templates/classifieds/edit.html b/templates/classifieds/edit.html index 99ebe86..6ac5a4f 100644 --- a/templates/classifieds/edit.html +++ b/templates/classifieds/edit.html @@ -120,7 +120,7 @@
- +
@@ -185,9 +185,14 @@ var quill = new Quill('#quill-editor', { }); quill.root.innerHTML = {{ classified.description|tojson }}; -document.querySelector('form').addEventListener('submit', function() { +document.querySelector('form').addEventListener('submit', function(e) { var html = quill.root.innerHTML; - if (html === '


') html = ''; + if (html === '


' || quill.getText().trim() === '') { + e.preventDefault(); + alert('Wpisz treść ogłoszenia.'); + quill.focus(); + return; + } document.getElementById('description').value = html; }); diff --git a/templates/classifieds/new.html b/templates/classifieds/new.html index cf66c8d..12b08e0 100755 --- a/templates/classifieds/new.html +++ b/templates/classifieds/new.html @@ -319,7 +319,7 @@
- +
@@ -368,10 +368,17 @@ var quill = new Quill('#quill-editor', { } }); -// Sync Quill content to hidden textarea on form submit -document.querySelector('form').addEventListener('submit', function() { +// Sync Quill content to hidden textarea on form submit + validate non-empty. +// Note: hidden textarea cannot use `required` (browser cannot show validation +// UI on display:none fields, which silently blocks submit). +document.querySelector('form').addEventListener('submit', function(e) { var html = quill.root.innerHTML; - if (html === '


') html = ''; + if (html === '


' || quill.getText().trim() === '') { + e.preventDefault(); + alert('Wpisz treść ogłoszenia.'); + quill.focus(); + return; + } document.getElementById('description').value = html; }); diff --git a/utils/markdown.py b/utils/markdown.py index 5184528..f6dd02e 100644 --- a/utils/markdown.py +++ b/utils/markdown.py @@ -56,13 +56,16 @@ def parse_forum_markdown(text, current_user_name=None): # Inline code (`code`) text = re.sub(r'`([^`]+)`', r'\1', text) - # Bold (**text** or __text__) + # Bold (**text** or __text__) — require non-word boundary on `_` form + # so URLs like `forestry_office` don't get partially bolded. text = re.sub(r'\*\*([^*]+)\*\*', r'\1', text) - text = re.sub(r'__([^_]+)__', r'\1', text) + text = re.sub(r'(^|\W)__([^_\n]+?)__(?=\W|$)', r'\1\2', text) - # Italic (*text* or _text_) - careful not to match bold - text = re.sub(r'(?\1', text) - text = re.sub(r'(?\1', text) + # Italic (*text* or _text_) — same boundary rule for `_` to avoid + # eating underscores inside URLs (e.g. ?g_ep=...) which corrupted forum + # links. The captured leading char is re-emitted. + text = re.sub(r'(?\1', text) + text = re.sub(r'(^|\W)_(?!_)([^_\n]+?)_(?=\W|$)', r'\1\2', text) # Links [text](url) - only allow http/https def safe_link(match):