diff --git a/app/helpers/html_to_string_helper.rb b/app/helpers/html_to_string_helper.rb
new file mode 100644
index 000000000..682bf536f
--- /dev/null
+++ b/app/helpers/html_to_string_helper.rb
@@ -0,0 +1,10 @@
+module HtmlToStringHelper
+ def html_to_string(html)
+ string_with_tags = html
+ .gsub(/
/, "\n")
+ .gsub('
', '')
+
+ strip_tags(string_with_tags)
+ end
+end
diff --git a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml
index 39f497c12..5e2b2164c 100644
--- a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml
+++ b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml
@@ -4,4 +4,4 @@
row: 6,
placeholder: champ.description,
required: champ.mandatory,
- value: sanitize(champ.value)
+ value: html_to_string(champ.value)
diff --git a/spec/helpers/html_to_string_helper_spec.rb b/spec/helpers/html_to_string_helper_spec.rb
new file mode 100644
index 000000000..444cf4805
--- /dev/null
+++ b/spec/helpers/html_to_string_helper_spec.rb
@@ -0,0 +1,21 @@
+describe HtmlToStringHelper do
+ describe "#html_to_string" do
+ describe 'does not change plain text' do
+ it { expect(helper.html_to_string('text')).to eq('text') }
+ end
+
+ describe 'deals with
' do
+ it { expect(helper.html_to_string('new
line')).to eq("new\nline") }
+ it { expect(helper.html_to_string('new
line')).to eq("new\nline") }
+ it { expect(helper.html_to_string('new
line')).to eq("new\nline") }
+ end
+
+ describe 'deals with
' do + it { expect(helper.html_to_string('
p1
p2
')).to eq("p1\np2\n") } + end + + describe 'strip other tags' do + it { expect(helper.html_to_string('italic')).to eq('italic') } + end + end +end