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

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

diff --git a/app/assets/javascripts/discourse/app/helpers/dir-span.js b/app/assets/javascripts/discourse/app/helpers/dir-span.js
index 022b2de..83efafb 100644
--- a/app/assets/javascripts/discourse/app/helpers/dir-span.js
+++ b/app/assets/javascripts/discourse/app/helpers/dir-span.js
@@ -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));
 });
diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.js
index 2fe8ea5..940bb5b 100644
--- a/app/assets/javascripts/discourse/app/models/category.js
+++ b/app/assets/javascripts/discourse/app/models/category.js
@@ -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];
diff --git a/app/assets/javascripts/discourse/app/templates/components/category-title-link.hbs b/app/assets/javascripts/discourse/app/templates/components/category-title-link.hbs
index 3f7ad86..43cec19 100644
--- a/app/assets/javascripts/discourse/app/templates/components/category-title-link.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/category-title-link.hbs
@@ -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
diff --git a/app/assets/javascripts/discourse/app/templates/components/parent-category-row.hbs b/app/assets/javascripts/discourse/app/templates/components/parent-category-row.hbs
index dbf5cc2..b6145eb 100644
--- a/app/assets/javascripts/discourse/app/templates/components/parent-category-row.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/parent-category-row.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/app/templates/components/sub-category-row.hbs b/app/assets/javascripts/discourse/app/templates/components/sub-category-row.hbs
index 9d9817b..44c142d 100644
--- a/app/assets/javascripts/discourse/app/templates/components/sub-category-row.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/sub-category-row.hbs
@@ -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}}
diff --git a/app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbr b/app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbr
index df1e710..08d8256 100644
--- a/app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbr
+++ b/app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbr
@@ -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}}
diff --git a/app/assets/javascripts/discourse/app/templates/navigation/category.hbs b/app/assets/javascripts/discourse/app/templates/navigation/category.hbs
index 94b8df9..1de4949 100644
--- a/app/assets/javascripts/discourse/app/templates/navigation/category.hbs
+++ b/app/assets/javascripts/discourse/app/templates/navigation/category.hbs
@@ -11,7 +11,7 @@
     }}
 
     {{#if category.description}}
-      <p>{{dir-span category.description}}</p>
+      <p>{{dir-span category.description false}}</p>
     {{/if}}
   {{/if}}
 
diff --git a/app/assets/javascripts/select-kit/addon/templates/components/category-row.hbs b/app/assets/javascripts/select-kit/addon/templates/components/category-row.hbs
index dfd630d..7779572 100644
--- a/app/assets/javascripts/select-kit/addon/templates/components/category-row.hbs
+++ b/app/assets/javascripts/select-kit/addon/templates/components/category-row.hbs
@@ -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}}

GitHub sha: e50a5c0c73d8f983286b50ac45e10ce52924269e

This commit appears in #14183 which was approved by tgxworld. It was merged by blake.