Skip to content

Commit d3b31b0

Browse files
committed
Avoid injection, use src to load html pages
1 parent 26628e8 commit d3b31b0

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

client/src/components/Dataset/DatasetDisplay.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const sanitizedToolId = ref();
3434
const { isAdmin } = storeToRefs(useUserStore());
3535
3636
const dataset = computed(() => getDataset(props.datasetId));
37-
const datasetUrl = computed(() => withPrefix(`/dataset/display?dataset_id=${props.datasetId}`));
38-
const downloadUrl = computed(() => withPrefix(`${datasetUrl.value}&to_ext=${dataset.value?.file_ext}`));
37+
const datasetUrl = computed(() => `/datasets/${props.datasetId}/display`);
38+
const downloadUrl = computed(() => withPrefix(`${datasetUrl.value}?to_ext=${dataset.value?.file_ext}`));
3939
const isLoading = computed(() => isLoadingDataset(props.datasetId));
4040
4141
const sanitizedMessage = computed(() => {
@@ -51,7 +51,7 @@ const sanitizedMessage = computed(() => {
5151
watch(
5252
() => props.datasetId,
5353
async () => {
54-
const url = withPrefix(`/datasets/${props.datasetId}/display/?preview=True`);
54+
const url = withPrefix(`${datasetUrl.value}?preview=True`);
5555
try {
5656
const { data, headers } = await axios.get(url);
5757
content.value = data;
@@ -98,7 +98,7 @@ watch(
9898
</div>
9999
<a :href="downloadUrl">Download</a>
100100
</div>
101-
<CenterFrame v-if="contentType === 'text/html'" :html="content" />
101+
<CenterFrame v-if="contentType === 'text/html'" :src="datasetUrl" />
102102
<pre v-else>{{ content }}</pre>
103103
</div>
104104
</div>

client/src/entry/analysis/modules/CenterFrame.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, onMounted, ref, watch } from "vue";
2+
import { computed, ref } from "vue";
33
44
import { withPrefix } from "@/utils/redirect";
55
@@ -10,25 +10,16 @@ const props = withDefaults(
1010
defineProps<{
1111
id?: string;
1212
src?: string;
13-
html?: string;
1413
}>(),
1514
{
1615
id: "frame",
1716
src: "",
18-
html: "",
1917
},
2018
);
2119
22-
const iframeRef = ref<HTMLIFrameElement>();
2320
const srcWithRoot = computed(() => withPrefix(props.src));
2421
const isLoading = ref(true);
2522
26-
function injectHtml(val: string) {
27-
if (iframeRef.value && val) {
28-
iframeRef.value.srcdoc = val;
29-
}
30-
}
31-
3223
function onLoad(ev: Event) {
3324
isLoading.value = false;
3425
const iframe = ev.currentTarget as HTMLIFrameElement;
@@ -41,19 +32,14 @@ function onLoad(ev: Event) {
4132
console.warn("[CenterFrame] onLoad location access forbidden.", ev, location);
4233
}
4334
}
44-
45-
watch(() => props.html, injectHtml);
46-
onMounted(() => injectHtml(props.html));
4735
</script>
48-
4936
<template>
5037
<div class="h-100">
5138
<LoadingSpan v-if="isLoading">Loading ...</LoadingSpan>
5239
<iframe
5340
:id="id"
54-
ref="iframeRef"
5541
:name="id"
56-
:src="props.html ? undefined : srcWithRoot"
42+
:src="srcWithRoot"
5743
class="center-frame"
5844
frameborder="0"
5945
title="galaxy frame"

0 commit comments

Comments
 (0)