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 { helperContext, registerUnbound } from "discourse-common/lib/helpers";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import { isRTL } from "discourse/lib/text-direction"; import { isRTL } from "discourse/lib/text-direction";
import { escapeExpression } from "discourse/lib/utilities";
function setDir(text) { function setDir(text) {
let content = text ? text : ""; let content = text ? text : "";
@ -12,6 +13,7 @@ function setDir(text) {
return content; return content;
} }
export default registerUnbound("dir-span", function (str) { export default registerUnbound("dir-span", function (str, escapeText = true) {
return htmlSafe(setDir(str)); 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 { get } from "@ember/object";
import { getOwner } from "discourse-common/lib/get-owner"; import { getOwner } from "discourse-common/lib/get-owner";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import { escapeExpression } from "discourse/lib/utilities";
const STAFF_GROUP_NAME = "staff"; const STAFF_GROUP_NAME = "staff";
@ -57,11 +56,6 @@ const Category = RestModel.extend({
return { type: "category", id, category: this }; return { type: "category", id, category: this };
}, },
@discourseComputed("name")
escapeName(name) {
return escapeExpression(name);
},
@discourseComputed("parentCategory.ancestors") @discourseComputed("parentCategory.ancestors")
ancestors(parentAncestors) { ancestors(parentAncestors) {
return [...(parentAncestors || []), this]; return [...(parentAncestors || []), this];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
</div> </div>
{{#if shouldDisplayDescription}} {{#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}} {{/if}}
{{else}} {{else}}
{{html-safe label}} {{html-safe label}}