FIX: Escape topic titles when `use_pg_headlines_for_excerpt` true (#24608)

This commit is contained in:
Isaac Janzen 2023-11-28 14:32:22 -07:00 committed by GitHub
parent 9576f3ec97
commit 9a909758ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -8,7 +8,7 @@
@result.topic_title_headline
)
}}
<span>{{replace-emoji @result.topic_title_headline}}</span>
<span>{{replace-emoji (html-safe @result.topic_title_headline)}}</span>
{{else}}
<SearchMenu::HighlightedSearch @string={{@result.topic.fancyTitle}} />
{{/if}}

View File

@ -556,6 +556,20 @@ acceptance("Search - Glimmer - Authenticated", function (needs) {
);
});
test("topic results - search result escapes html in topic title when use_pg_headlines_for_excerpt is true", async function (assert) {
this.siteSettings.use_pg_headlines_for_excerpt = true;
await visit("/");
await click("#search-button");
await fillIn("#search-term", "dev");
await triggerKeyEvent("#search-term", "keyup", "Enter");
assert
.dom(
".search-menu .search-result-topic .item:first-of-type .topic-title span.search-highlight"
)
.exists("html in the topic title is properly escaped");
});
test("search menu keyboard navigation", async function (assert) {
const container = ".search-menu .results";
await visit("/");

View File

@ -84,6 +84,7 @@ export default {
yours: false,
topic_id: 2179,
topic_slug: "development-mode-super-slow",
topic_title_headline: "<span class='search-highlight'>Dev</span>opment mode super slow",
display_username: "Bill Dudney",
primary_group_name: null,
version: 2,