diff --git a/lacommunaute/forum/forms.py b/lacommunaute/forum/forms.py
index c86796c65..24e6ee178 100644
--- a/lacommunaute/forum/forms.py
+++ b/lacommunaute/forum/forms.py
@@ -1,5 +1,3 @@
-import re
-
from django import forms
from django.conf import settings
from django.forms import CharField, CheckboxSelectMultiple, ModelMultipleChoiceField
@@ -7,19 +5,7 @@
from lacommunaute.forum.models import Forum
from lacommunaute.partner.models import Partner
-
-
-def wrap_iframe_in_div_tag(text):
- # iframe tags must be wrapped in a div tag to be displayed correctly
- # add div tag if not present
-
- iframe_regex = r"((
)?(
)?)"
-
- for match, starts_with, ends_with in re.findall(iframe_regex, text, re.DOTALL):
- if not starts_with and not ends_with:
- text = text.replace(match, f"{match}
")
-
- return text
+from lacommunaute.utils.html import wrap_iframe_in_div_tag
class ForumForm(forms.ModelForm):
diff --git a/lacommunaute/utils/html.py b/lacommunaute/utils/html.py
new file mode 100644
index 000000000..3d9949736
--- /dev/null
+++ b/lacommunaute/utils/html.py
@@ -0,0 +1,14 @@
+import re
+
+
+def wrap_iframe_in_div_tag(text):
+ # iframe tags must be wrapped in a div tag to be displayed correctly
+ # add div tag if not present
+
+ iframe_regex = r"((