Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: double escape (#19565)

ecmadao5163b86e72e6
diff --git a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/Label.vue b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/Label.vue
index b4ba4fa37c..b63e18d48f 100644
--- a/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/Label.vue
+++ b/frontend/src/components/GrantRequestPanel/DatabaseResourceForm/Label.vue
@@ -18,7 +18,6 @@
<script setup lang="ts">
import { computedAsync } from "@vueuse/core";
-import { escape } from "lodash-es";
import { computed, h } from "vue";
import { EnvironmentV1Name, InstanceV1Name } from "@/components/v2";
import { useDatabaseV1Store } from "@/store";
@@ -73,10 +72,6 @@ const optionName = computed(() => {
const name = option.value?.label ?? "";
const keyword = (props.keyword ?? "").trim();
- return getHighlightHTMLByRegExp(
- escape(name),
- escape(keyword),
- false /* !caseSensitive */
- );
+ return getHighlightHTMLByRegExp(name, keyword, false /* !caseSensitive */);
});
</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue
index 1e70e9ffa6..c29f99672b 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/AccessGrantView/AccessGrantDetailsSection.vue
@@ -41,12 +41,12 @@
>
{{ $t("sql-editor.unmask-warning") }}
</BBAttention>
- <div
- class="max-h-[10em] overflow-auto border rounded-sm p-2 font-mono text-sm whitespace-pre-wrap"
- >
- {{ accessGrant.query }}
+ <div class="max-h-[30em] overflow-auto rounded-xs p-4 bg-gray-50">
+ <NConfigProvider :hljs="hljs">
+ <NCode language="sql" :code="accessGrant.query" />
+ </NConfigProvider>
</div>
- <NCheckbox :checked="accessGrant.unmask" :readonly="true">
+ <NCheckbox :checked="accessGrant.unmask" :disabled="true">
<span class="text-base">
{{ $t("sql-editor.access-type-unmask") }}
</span>
@@ -80,7 +80,8 @@
</template>
<script lang="ts" setup>
-import { NCheckbox } from "naive-ui";
+import hljs from "highlight.js/lib/core";
+import { NCheckbox, NCode, NConfigProvider } from "naive-ui";
import { computed, ref, watchEffect } from "vue";
import { BBAttention, BBSpin } from "@/bbkit";
import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
diff --git a/frontend/src/components/SchemaDiagram/Navigator/TreeNode/Label.vue b/frontend/src/components/SchemaDiagram/Navigator/TreeNode/Label.vue
index bd50fae99a..b2cfc51ddc 100644
--- a/frontend/src/components/SchemaDiagram/Navigator/TreeNode/Label.vue
+++ b/frontend/src/components/SchemaDiagram/Navigator/TreeNode/Label.vue
@@ -13,7 +13,6 @@
</template>
<script lang="ts" setup>
-import { escape } from "lodash-es";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { getHighlightHTMLByKeyWords } from "@/utils";
@@ -40,6 +39,6 @@ const text = computed(() => {
});
const html = computed(() => {
- return getHighlightHTMLByKeyWords(escape(text.value), escape(props.keyword));
+ return getHighlightHTMLByKeyWords(text.value, props.keyword);
});
</script>
diff --git a/frontend/src/components/SchemaEditorLite/Aside/Tree.vue b/frontend/src/components/SchemaEditorLite/Aside/Tree.vue
index 5dc977f4fd..6c83219c11 100644
--- a/frontend/src/components/SchemaEditorLite/Aside/Tree.vue
+++ b/frontend/src/components/SchemaEditorLite/Aside/Tree.vue
@@ -96,7 +96,7 @@
<script lang="ts" setup>
import { refDebounced, useElementSize } from "@vueuse/core";
import { MD5 } from "crypto-js";
-import { cloneDeep, debounce, escape, head } from "lodash-es";
+import { cloneDeep, debounce, head } from "lodash-es";
import { CopyIcon, MoreHorizontalIcon } from "lucide-vue-next";
import type { TreeOption } from "naive-ui";
import { NDropdown, NPerformantEllipsis, NTree } from "naive-ui";
@@ -559,10 +559,7 @@ const renderLabel = ({ option }: { option: TreeOption }) => {
},
() => [
h("span", {
- innerHTML: getHighlightHTMLByKeyWords(
- escape(label),
- escape(searchPattern.value)
- ),
+ innerHTML: getHighlightHTMLByKeyWords(label, searchPattern.value),
}),
]
);
diff --git a/frontend/src/components/v2/Model/HighlightLabelText.vue b/frontend/src/components/v2/Model/HighlightLabelText.vue
index 233d673e7e..21ad2955fa 100644
--- a/frontend/src/components/v2/Model/HighlightLabelText.vue
+++ b/frontend/src/components/v2/Model/HighlightLabelText.vue
@@ -5,7 +5,6 @@
</template>
<script lang="ts" setup>
-import { escape } from "lodash-es";
import { computed } from "vue";
import { getHighlightHTMLByRegExp } from "@/utils";
@@ -16,8 +15,8 @@ const props = defineProps<{
const html = computed(() => {
return getHighlightHTMLByRegExp(
- escape(props.text),
- escape(props.keyword?.trim() ?? ""),
+ props.text,
+ props.keyword?.trim() ?? "",
false /* !caseSensitive */
);
});
diff --git a/frontend/src/views/project/ProjectGitOpsDashboard.vue b/frontend/src/views/project/ProjectGitOpsDashboard.vue
index 303f1d9567..9cab802cef 100644
--- a/frontend/src/views/project/ProjectGitOpsDashboard.vue
+++ b/frontend/src/views/project/ProjectGitOpsDashboard.vue
@@ -302,15 +302,15 @@
<div class="flex flex-col gap-y-2">
<div class="flex items-center gap-x-2">
<span class="text-sm text-control-light font-bold">{{ sampleFilePath }}</span>
- <CopyButton :content="sampleSql" />
</div>
- <NInput
- :value="sampleSql"
- type="textarea"
- readonly
- :autosize="{ minRows: 5, maxRows: 15 }"
- class="font-mono text-sm"
- />
+ <div class="relative rounded-xs p-4 bg-gray-50">
+ <div class="absolute top-2 right-2 p-2">
+ <CopyButton size="medium" :content="sampleSql" />
+ </div>
+ <NConfigProvider :hljs="hljs">
+ <NCode language="sql" :code="sampleSql" />
+ </NConfigProvider>
+ </div>
</div>
<!-- Step-by-step instructions -->
@@ -378,7 +378,6 @@ import {
NButton,
NCode,
NConfigProvider,
- NInput,
NSwitch,
NTabPane,
NTabs,
diff --git a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
index f5f1ddef50..3a30f8afc0 100644
--- a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
@@ -67,7 +67,6 @@
<script lang="ts" setup>
import { useDebounceFn } from "@vueuse/core";
import dayjs from "dayjs";
-import { escape } from "lodash-es";
import { NButton } from "naive-ui";
import { computed, reactive, watch } from "vue";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
@@ -140,9 +139,7 @@ watch(
);
const getFormattedStatement = (statement: string) => {
- return state.search
- ? getHighlightHTMLByKeyWords(escape(statement), escape(state.search))
- : escape(statement);
+ return getHighlightHTMLByKeyWords(statement, state.search);
};
const titleOfQueryHistory = (history: QueryHistory) => {
diff --git a/frontend/src/views/sql-editor/AsidePanel/WorksheetPane/SheetList/common.ts b/frontend/src/views/sql-editor/AsidePanel/WorksheetPane/SheetList/common.ts
index 7f9e18e8a0..2d78975a60 100644
--- a/frontend/src/views/sql-editor/AsidePanel/WorksheetPane/SheetList/common.ts
+++ b/frontend/src/views/sql-editor/AsidePanel/WorksheetPane/SheetList/common.ts
@@ -1,17 +1,10 @@
-import { escape } from "lodash-es";
import type { TreeOption } from "naive-ui";
import { getHighlightHTMLByRegExp } from "@/utils";
export const titleHTML = (title: string, keyword: string) => {
- const kw = keyword.toLowerCase().trim();
-
- if (!kw) {
- return escape(title);
- }
-
return getHighlightHTMLByRegExp(
- escape(title),
- escape(kw),
+ title,
+ keyword.toLowerCase().trim(),
false /* !caseSensitive */
);
};
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
index 3690bb32a8..051cb4bde6 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/TableCell.vue
@@ -52,7 +52,6 @@
<script setup lang="ts">
import { useResizeObserver } from "@vueuse/core";
-import { escape } from "lodash-es";
import { ExpandIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { twMerge } from "tailwind-merge";
@@ -205,15 +204,7 @@ const html = computed(() => {
if (!kw) {
kw = props.keyword.trim();
}
- if (!kw) {
- return escape(value);
- }
-
- return getHighlightHTMLByRegExp(
- value,
- escape(kw),
- false /* !caseSensitive */
- );
+ return getHighlightHTMLByRegExp(value, kw, false /* !caseSensitive */);
});
const handleClick = (e: MouseEvent) => {
diff --git a/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue b/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
index aa3f9e6466..874d397ad4 100644
--- a/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
@@ -19,7 +19,6 @@
</template>
<script setup lang="ts">
-import { escape } from "lodash-es";
import { NPerformantEllipsis } from "naive-ui";
import { computed } from "vue";
import { getHighlightHTMLByRegExp, type VueClass } from "@/utils";
@@ -38,13 +37,9 @@ const props = defineProps<{
const html = computed(() => {
const { content, keyword } = props;
- const kw = (keyword ?? "").trim();
- if (!kw) {
- return escape(content);
- }
return getHighlightHTMLByRegExp(
- escape(content),
- escape(kw),
+ content,
+ (keyword ?? "").trim(),
false /* !caseSensitive */
);
});
@@ -52,13 +47,9 @@ const html = computed(() => {
const tooltipHTML = computed(() => {
const { keyword, tooltip } = props;
if (typeof tooltip === "string") {
- const kw = (keyword ?? "").trim();
- if (!kw) {
- return escape(tooltip);
- }
return getHighlightHTMLByRegExp(
- escape(tooltip),
- escape(kw),
+ tooltip,
+ (keyword ?? "").trim(),
false /* !caseSensitive */
);
}