Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/components/record/mods_document_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<%= render Searchworks4::DocumentSectionLayout.new(title: 'Abstract/Contents', dl_classes: 'dl-horizontal dl-text') do %>
<% document.mods.abstract.each do |abstract| %>
<div class="my-2">
<%= truncated_mods_record_field(abstract, value_transformer: ->(v) { tag.div v, data: { 'long-text-target' => 'text' } } ) %>
<%= truncated_mods_record_field(abstract, value_transformer: ->(v) { tag.div CGI.unescapeHTML(v), data: { 'long-text-target' => 'text' } } ) %>
</div>
<% end %>

Expand Down
9 changes: 9 additions & 0 deletions spec/components/record/mods_document_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,13 @@
expect(page).to have_css("dd", text: "amazing")
end
end

describe 'when the abstract has ASCII characters' do
let(:document) { SolrDocument.new(modsxml: mods_ascii_abstract) }

it "translates or removes ASCII character encodings" do
expect(page).to have_no_content("&#13;")
expect(page).to have_css("dd", text: "This work was finished by January 2025.\n\nThis record is about this work.")
end
end
end
12 changes: 12 additions & 0 deletions spec/fixtures/mods_records/mods_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,16 @@ def mods_preferred_citation
</mods>
xml
end

def mods_ascii_abstract
<<-xml
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">
<titleInfo>
<title>A record with ascii in abstract</title>
</titleInfo>
<abstract>This work was finished by January 2025.&#13;\n&#13;\nThis record is about this work.</abstract>
</mods>
xml
end
end