Skip to content

Commit fd7a30c

Browse files
committed
Sanitize summary field in search results
Why are these changes being introduced: * Some summaries had HTML tags that were being rendered as text in the search results. Sanitizing the summary field allows certain HTML tags to be rendered properly while stripping out potentially harmful tags. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-297 How does this address that need: * Uses rails `sanitize` helper to allow certain HTML tags in the summary field while stripping out others. Document any side effects to this change: * I'm using sanitize with no parameters which seems to look good. If we find we want slightly different behavior we can dig deeper into what tags/attributes to allow.
1 parent 952d7b6 commit fd7a30c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/views/search/_result.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<% if result[:summary].present? %>
4949
<div class="result-summary truncate-list">
50-
<span class="sr">Summary: </span><%= result[:summary] %>
50+
<span class="sr">Summary: </span><%= sanitize result[:summary] %>
5151
</div>
5252
<% end %>
5353
</div>

app/views/search/_result_primo.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<% if result[:summary].present? %>
5656
<div class="result-summary truncate-list">
57-
<span class="sr">Summary: </span><%= result[:summary] %>
57+
<span class="sr">Summary: </span><%= sanitize result[:summary] %>
5858
</div>
5959
<% end %>
6060
</div>

0 commit comments

Comments
 (0)