Escape HTML when displaying search results

This commit is contained in:
Francesco Siddi 2017-05-31 17:14:14 +02:00
parent a806f294b2
commit d67f65019e
4 changed files with 10 additions and 8 deletions

View File

@ -37,10 +37,10 @@ $(document).ready(function() {
hitFree +
'</div>' +
'<div class="search-hit-name" title="' + hit.name + '">' +
hit._highlightResult.name.value + ' ' +
hit.name + ' ' +
'</div>' +
'<div class="search-hit-meta">' +
'<span class="project">' + hit._highlightResult.project.name.value + '</span> · ' +
'<span class="project">' + hit.project.name + '</span> · ' +
'<span class="node_type">' + hit.node_type + '</span>' +
hitMedia +
'</div>' +

View File

@ -134,9 +134,9 @@ script(type="text/template", id="hit-template")
span free
| {{/is_free}}
.search-hit-name
| {{{ _highlightResult.name.value }}}
| {{ name }}
.search-hit-meta
span.project {{{ project.name }}} ·
span.project {{ project.name }}
span.node_type {{{ node_type }}}
| {{#media}}
span.media · {{{ media }}}

View File

@ -96,7 +96,9 @@ script.
limit: 10,
templates: {
suggestion: function (hit) {
return hit._highlightResult.full_name.value + ' (' + hit._highlightResult.username.value + ')';
var suggestion = hit.full_name + ' (' + hit.username + ')';
var $p = $('p').text(suggestion);
return $p.html();
}
}
}

View File

@ -55,10 +55,10 @@ script(type="text/template", id="facet-template")
script(type="text/template", id="hit-template")
.search-hit.users(data-user-id='{{ objectID }}')
.search-hit-name
| {{{ _highlightResult.full_name.value }}}
small ({{{ username }}})
| {{ full_name }}
small ({{ username }})
.search-hit-roles
| {{{ roles }}}
| {{ roles }}
// Pagination template