From af5ab7bcd74e5bc18b4a0929d797b6758141a801 Mon Sep 17 00:00:00 2001
From: Patrick Golden
Date: Thu, 21 Nov 2024 12:00:01 -0500
Subject: [PATCH] Eliminate use of v-html when rendering node names and
descriptions (#908)
### Related issues
- Closes #902
### Summary
- Adds a new component, `` which safely renders text
containing ``, ``, and `` tags, while also leaving arbitrary
text \ untouched.
- Removes the usage of the unsafe `v-html` directive when rendering
nodes, replacing it with ``
### Checks
- [x] All tests have passed (or issues created for failing tests)
---------
Co-authored-by: Patrick Golden
---
frontend/src/components/AppNodeBadge.vue | 10 +-
frontend/src/components/AppNodeText.vue | 228 ++++++++++++++++++++
frontend/src/pages/node/SectionOverview.vue | 14 +-
frontend/src/pages/node/SectionTitle.vue | 3 +-
4 files changed, 244 insertions(+), 11 deletions(-)
create mode 100644 frontend/src/components/AppNodeText.vue
diff --git a/frontend/src/components/AppNodeBadge.vue b/frontend/src/components/AppNodeBadge.vue
index 449167e6..4f210f4e 100644
--- a/frontend/src/components/AppNodeBadge.vue
+++ b/frontend/src/components/AppNodeBadge.vue
@@ -18,10 +18,13 @@
? { breadcrumbs: [...currentBreadcrumbs, ...breadcrumbs] }
: state || undefined
"
- v-html="name"
- >
+ >
+
+
-
+
+
+
({{ info }})
@@ -31,6 +34,7 @@
import { computed } from "vue";
import { getCategoryIcon, getCategoryLabel } from "@/api/categories";
import type { Node } from "@/api/model";
+import AppNodeText from "@/components/AppNodeText.vue";
import { breadcrumbs as currentBreadcrumbs } from "@/global/breadcrumbs";
import type { Breadcrumb } from "@/global/breadcrumbs";
diff --git a/frontend/src/components/AppNodeText.vue b/frontend/src/components/AppNodeText.vue
new file mode 100644
index 00000000..a5980315
--- /dev/null
+++ b/frontend/src/components/AppNodeText.vue
@@ -0,0 +1,228 @@
+
+
+
+
+ {{ text }}
+
+
+ {{ text }}
+
+
+
+
+
+
diff --git a/frontend/src/pages/node/SectionOverview.vue b/frontend/src/pages/node/SectionOverview.vue
index 85e3e44c..fda894be 100644
--- a/frontend/src/pages/node/SectionOverview.vue
+++ b/frontend/src/pages/node/SectionOverview.vue
@@ -31,8 +31,9 @@
v-tooltip="'Click to expand'"
class="description truncate-10"
tabindex="0"
- v-html="node.description?.trim()"
- >
+ >
+
+
@@ -71,11 +72,9 @@
title="Also Known As"
:full="true"
>
-
+
+
+
@@ -155,6 +154,7 @@ import type { Node } from "@/api/model";
import AppDetail from "@/components/AppDetail.vue";
import AppDetails from "@/components/AppDetails.vue";
import AppNodeBadge from "@/components/AppNodeBadge.vue";
+import AppNodeText from "@/components/AppNodeText.vue";
import { scrollTo } from "@/router";
import { sleep } from "@/util/debug";
diff --git a/frontend/src/pages/node/SectionTitle.vue b/frontend/src/pages/node/SectionTitle.vue
index 15dca5f3..0ee1c0f4 100644
--- a/frontend/src/pages/node/SectionTitle.vue
+++ b/frontend/src/pages/node/SectionTitle.vue
@@ -26,8 +26,8 @@
>
+
(OBSOLETE)
@@ -48,6 +48,7 @@ import { computed } from "vue";
import { truncate } from "lodash";
import { getCategoryIcon, getCategoryLabel } from "@/api/categories";
import type { Node } from "@/api/model";
+import AppNodeText from "@/components/AppNodeText.vue";
import { parse } from "@/util/object";
type Props = {