DEV: Add default on encoding to dir-span (#14183)

This commit is contained in:
Blake Erickson 2021-08-30 11:25:12 -06:00 committed by GitHub
parent ed688bec8c
commit e50a5c0c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 14 deletions

View File

@ -1,6 +1,7 @@
import { helperContext, registerUnbound } from "discourse-common/lib/helpers";
import { htmlSafe } from "@ember/template";
import { isRTL } from "discourse/lib/text-direction";
import { escapeExpression } from "discourse/lib/utilities";
function setDir(text) {
let content = text ? text : "";
@ -12,6 +13,7 @@ function setDir(text) {
return content;
}
export default registerUnbound("dir-span", function (str) {
return htmlSafe(setDir(str));
export default registerUnbound("dir-span", function (str, escapeText = true) {
let text = escapeText ? escapeExpression(str) : str;
return htmlSafe(setDir(text));
});

View File

@ -8,7 +8,6 @@ import { ajax } from "discourse/lib/ajax";
import { get } from "@ember/object";
import { getOwner } from "discourse-common/lib/get-owner";
import getURL from "discourse-common/lib/get-url";
import { escapeExpression } from "discourse/lib/utilities";
const STAFF_GROUP_NAME = "staff";
@ -57,11 +56,6 @@ const Category = RestModel.extend({
return { type: "category", id, category: this };
},
@discourseComputed("name")
escapeName(name) {
return escapeExpression(name);
},
@discourseComputed("parentCategory.ancestors")
ancestors(parentAncestors) {
return [...(parentAncestors || []), this];

View File

@ -4,7 +4,7 @@
{{#if category.read_restricted}}
{{d-icon lockIcon}}
{{/if}}
<span class="category-name">{{dir-span category.escapeName}}</span>
<span class="category-name">{{dir-span category.name}}</span>
</div>
{{#if category.uploaded_logo.url}}
{{cdn-img

View File

@ -5,7 +5,7 @@
{{category-title-link category=category}}
{{#if category.description_excerpt}}
<div class="category-description">
{{dir-span category.description_excerpt}}
{{dir-span category.description_excerpt false}}
</div>
{{/if}}
{{#if category.isGrandParent}}

View File

@ -4,7 +4,7 @@
{{category-title-link tagName="h4" category=category}}
{{#if category.description_excerpt}}
<div class="category-description subcategory-description">
{{dir-span category.description_excerpt}}
{{dir-span category.description_excerpt false}}
</div>
{{/if}}
{{#if category.subcategories}}

View File

@ -1,6 +1,6 @@
{{#if topic.hasExcerpt}}
<a href="{{topic.url}}" class="topic-excerpt">
{{dir-span topic.escapedExcerpt}}
{{dir-span topic.escapedExcerpt false}}
{{#if topic.excerptTruncated}}
<span class="topic-excerpt-more">{{i18n 'read_more'}}</span>
{{/if}}

View File

@ -11,7 +11,7 @@
}}
{{#if category.description}}
<p>{{dir-span category.description}}</p>
<p>{{dir-span category.description false}}</p>
{{/if}}
{{/if}}

View File

@ -9,7 +9,7 @@
</div>
{{#if shouldDisplayDescription}}
<div class="category-desc" aria-hidden="true">{{dir-span description}}</div>
<div class="category-desc" aria-hidden="true">{{dir-span description false}}</div>
{{/if}}
{{else}}
{{html-safe label}}