diff --git a/app/helpers/record_helper.rb b/app/helpers/record_helper.rb index d9a16f71e..652ebe61e 100644 --- a/app/helpers/record_helper.rb +++ b/app/helpers/record_helper.rb @@ -34,4 +34,11 @@ def linked_mods_genres(genres) end end.join('').html_safe end + + ## + # Expose format_mods_html from mods_display to properly encode content as needed + # RecordHelper behavior + def format_record_html(...) + format_mods_html(...) + end end diff --git a/app/views/catalog/mastheads/_collection.html.erb b/app/views/catalog/mastheads/_collection.html.erb index a221b1ac2..c30527da9 100644 --- a/app/views/catalog/mastheads/_collection.html.erb +++ b/app/views/catalog/mastheads/_collection.html.erb @@ -7,7 +7,7 @@ <% if @parent[:summary_display] %>
- <%= @parent[:summary_display].join(', ') %> + <%= format_record_html(@parent[:summary_display].join(', ')) %>
<% end %> diff --git a/spec/helpers/record_helper_spec.rb b/spec/helpers/record_helper_spec.rb index c38bc843b..d3c09a85e 100644 --- a/spec/helpers/record_helper_spec.rb +++ b/spec/helpers/record_helper_spec.rb @@ -20,4 +20,22 @@ end end end + + describe 'record html' do + context 'when the record has line feeds in the string' do + let(:html) { "some text\r\nsome other text" } + + it 'returns the string without changing the encoding' do + expect(helper.format_record_html(html)).to eq "some text\r\nsome other text" + end + end + + context 'when the record has encoded line feeds in the string' do + let(:html) { "some text \nsome other text" } + + it 'returns the string with proper encoding' do + expect(helper.format_record_html(html)).to eq "some text\r\nsome other text" + end + end + end end